PJSIP_Header content to Broker

Hello everyone,

I am receiving a SIP Invite on my Asterisk server and I need to receive the header fields and send them to broker such as rabbitmq. I am stuck on what function I need to write on my dialplan to send the headers to broker. I’ve checked Asterisk Dialplan Commands but there is nothing that mentions sending to a broker, Please any suggestions will be appreciated. For rabbitmq module on asterisk I am following this guide amqp

extensions.conf

[sip_invite]
exten => _XX.,1,NoOp(Call from ${CALLERID(num)} to ${EXTEN})
same => n,Set(via=${PJSIP_HEADER(read,Via)})
same => n,Set(fromSource=${PJSIP_HEADER(read,From)})
same => n,Set(ToDestination=${PJSIP_HEADER(read,To)})
same => n,Set(CallID=${PJSIP_HEADER(read,Call-ID)})
same => n,Set(diversion=${PJSIP_HEADER(read,Diversion)})
same => n,Answer()

Asterisk has no built in support for it, if you’re using an external third party module you’d need to examine its documentation or use its resources to determine how it is to be used.

Hey Joshua,

While reading the guide I noticed that two configuration files in my etc/asterisk directory can be created res_amqp.so, res_stasis_amqp.so, so I assumed there is an integration from Asterisk to rabbitMQ. I am not using a third party module, My goal is to receive a SIP Invite that contains a message on my Asterisk and send it to my broker. First idea was to use stasis ARI to receive the message but I did not find a function that receives SIP invite header fields on StasisStart so my second plan was to use dialplan. Please note that I am using ari4java library for my stasis application.

The res_amqp and res_stasis_amqp files are third party modules, they are not included with Asterisk. How you get the files, use them, etc, are not documented or specified by the project. Dialplan functions can be used in ARI by using get variable[1], how you do that in ari4java I do not know. The Stasis application in the dialplan also allows passing in arguments[2] which are placed in the StasisStart.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Channels+REST+API#Asterisk16ChannelsRESTAPI-getChannelVar
[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Application_Stasis

Great, then I will receive the SIP Invite message from dialplan and send them to my Stasis application as arguments. My extensions config would look like this:

> [sip_invite]
> exten => _XX.,1,NoOp(Call from ${CALLERID(num)} to ${EXTEN})
>  same =>      n,Set(via=${PJSIP_HEADER(read,Via)})
>  same =>      n,Set(fromSource=${PJSIP_HEADER(read,From)})
>  same =>      n,Set(ToDestination=${PJSIP_HEADER(read,To)})
>  same =>      n,Set(CallID=${PJSIP_HEADER(read,Call-ID)})
>  same =>      n,Set(diversion=${PJSIP_HEADER(read,Diversion)})
>  same =>      n,Stasis(Intro-IVR, [via,fromSource,ToDestination,CallID,diversion])
>  same =>      n,Hangup()

Thank you for your help Joshua.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.