Asterisk Integration - Manipulate Asterisk Contexts

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Asterisk Integration - Manipulate Asterisk Contexts

osiris123d
I have set up Asterisk to work with OpenSIPS so that instead of the context for all OpenSIPS Subscribers being "default" it is their actual domain.  Following the OpenSIPS Tutorial to integrate with Asterisk worked well with this until it came time for a XYZ@DomainA to call a ABC@DomainB.  XYZ@DomainA gets sent to ABC@DomainB's voicemail if they don't pick up.  Well with multiple contexts set up with Asterisk XYZ@DomainA is going to be funnelled into Asterisk context DomainA since he is apart of Context DomainA.  This isn't good since context DomainA doesn't have a user called ABC

I found a way around this

With OpenSIPS I do the following
if($rd != $var(callee_domain)){
        prefix("VMS_");
        append_hf("P-Asserted-Identity: $var(callee_domain)\r\n");
}
else{
        prefix("VMR_");
}
rewritehostport("ASTERISK_IP");


And in Asterisk I did this

; Leave Voicemail for DomainA.com employee from External DID
exten => _VMR_.,1,Ringing
exten => _VMR_.,n,Wait(1)
exten => _VMR_.,n,Answer
exten => _VMR_.,n,Wait(1)
exten => _VMR_.,n,Voicemail(${EXTEN:4}@coolbeans.com,u)
exten => _VMR_.,n,Hangup

; Leave Voicemail for other customer when DomainA.com employee calls them
exten => _VMS_.,1,Ringing
exten => _VMS_.,n,Wait(1)
exten => _VMS_.,n,Answer
exten => _VMS_.,n,Wait(1)
exten => _VMS_.,n,NoOp(${SIP_HEADER(P-Asserted-Identity)})
exten => _VMS_.,n,Voicemail(${EXTEN:4}@${SIP_HEADER(P-Asserted-Identity)},u)
exten => _VMS_.,n,Hangup






This works!!!!!!  But what I want to know is am I breaking some rules here by appending a P-Asserted-Identity SIP header and then looking for it in Asterisk????  

Comments???
Reply | Threaded
Open this post in threaded view
|

Re: Asterisk Integration - Manipulate Asterisk Contexts

Bogdan-Andrei Iancu
Hi,

Have you tried :

exten => _VMR_.,n,Voicemail(${EXTEN:4}@{SIPDOMAIN},u)

**
Regards,
Bogdan

osiris123d wrote:

> I have set up Asterisk to work with OpenSIPS so that instead of the context
> for all OpenSIPS Subscribers being "default" it is their actual domain.
> Following the OpenSIPS Tutorial to integrate with Asterisk worked well with
> this until it came time for a XYZ@DomainA to call a ABC@DomainB.
> XYZ@DomainA gets sent to ABC@DomainB's voicemail if they don't pick up.
> Well with multiple contexts set up with Asterisk XYZ@DomainA is going to be
> funnelled into Asterisk context DomainA since he is apart of Context
> DomainA.  This isn't good since context DomainA doesn't have a user called
> ABC
>
> I found a way around this
>
> With OpenSIPS I do the following
> if($rd != $var(callee_domain)){
> prefix("VMS_");
> append_hf("P-Asserted-Identity: $var(callee_domain)\r\n");
> }
> else{
>         prefix("VMR_");
> }
> rewritehostport("ASTERISK_IP");
>
>
> And in Asterisk I did this
>
> ; Leave Voicemail for DomainA.com employee from External DID
> exten => _VMR_.,1,Ringing
> exten => _VMR_.,n,Wait(1)
> exten => _VMR_.,n,Answer
> exten => _VMR_.,n,Wait(1)
> exten => _VMR_.,n,Voicemail(${EXTEN:4}@coolbeans.com,u)
> exten => _VMR_.,n,Hangup
>
> ; Leave Voicemail for other customer when DomainA.com employee calls them
> exten => _VMS_.,1,Ringing
> exten => _VMS_.,n,Wait(1)
> exten => _VMS_.,n,Answer
> exten => _VMS_.,n,Wait(1)
> exten => _VMS_.,n,NoOp(${SIP_HEADER(P-Asserted-Identity)})
> exten => _VMS_.,n,Voicemail(${EXTEN:4}@${SIP_HEADER(P-Asserted-Identity)},u)
> exten => _VMS_.,n,Hangup
>
>
>
>
>
>
> This works!!!!!!  But what I want to know is am I breaking some rules here
> by appending a P-Asserted-Identity SIP header and then looking for it in
> Asterisk????  
>
> Comments???
>  


--
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
15 - 19 November 2010, Edison, New Jersey, USA
www.voice-system.ro


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Asterisk Integration - Manipulate Asterisk Contexts

osiris123d
I can't use {SIPDOMAIN} because the {SIPDOMAIN} variable is actually the IP address of callers phone as it appears in the location table.

On a side note I was able to not use P-Asserted-Identity.  because of a different issue I learned about the uac_replace_to() function.  I was able to place the real domain in the TO header.  Now with Asterisk I do the following

exten => _VMS_.,1,Ringing
exten => _VMS_.,n,Wait(1)
exten => _VMS_.,n,Answer
exten => _VMS_.,n,Wait(1)    
exten => _VMS_.,n,Set(dm=${SIP_HEADER(TO):16})
exten => _VMS_.,n,Set(dm=${CUT(dm,>,1)})
exten => _VMS_.,n,Voicemail(${EXTEN:4}@${dm},u)
exten => _VMS_.,n,Hangup

The offsets I use above assumes the username of the extension being called is a 10 digit users NPANXXXXXX

Thanks for the reply.  The uac_replace_to() fixed multiple issues.

Reply | Threaded
Open this post in threaded view
|

Re: Asterisk Integration - Manipulate Asterisk Contexts

Mike O'Connor
On 9/11/10 3:55 AM, osiris123d wrote:

> I can't use {SIPDOMAIN} because the {SIPDOMAIN} variable is actually the IP
> address of callers phone as it appears in the location table.
>
> On a side note I was able to not use P-Asserted-Identity.  because of a
> different issue I learned about the uac_replace_to() function.  I was able
> to place the real domain in the TO header.  Now with Asterisk I do the
> following
>
> exten => _VMS_.,1,Ringing
> exten => _VMS_.,n,Wait(1)
> exten => _VMS_.,n,Answer
> exten => _VMS_.,n,Wait(1)    
> exten => _VMS_.,n,Set(dm=${SIP_HEADER(TO):16})
> exten => _VMS_.,n,Set(dm=${CUT(dm,>,1)})
> exten => _VMS_.,n,Voicemail(${EXTEN:4}@${dm},u)
> exten => _VMS_.,n,Hangup
>
> The offsets I use above assumes the username of the extension being called
> is a 10 digit users NPANXXXXXX
>
> Thanks for the reply.  The uac_replace_to() fixed multiple issues.
>
>
Hi Osiris

I suggest that your use something like this for your cut

[macro-find-did-in-string]
exten => s,1,Set(string=${ARG1})
exten => s,n,Set(result=${ARG2})
exten => s,n,Set(left=${CUT(string|@|1)})
exten => s,n,Set(${result}=${CUT(left|:|2)})

This will give you the DID even it its not 10 digits

Cheers
Mike


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Asterisk Integration - Manipulate Asterisk Contexts

osiris123d
Thanks for the suggestion Mike.