Add Custom SIP Header for Calls

1. Introduction

S-Series VoIP PBX supports dialplan function PJSIP_HEADER(), you can use this function to add custom SIP header in SIP INVITE request.

By this, you can implement like Distinctive Ring Tone feature for internal calls.

2. General steps 

1) Add variable to store the header value

2) Use subroutines Pre-Dial handler to add sip header when dialing out.

We use pre-dial option b in Dial function

The 'b' option in an application executes a dialplan subroutine on each callee channel after it is created but before the call is placed to the end-device.

3. Examples

Refer the config file customization guide: How to Create Custom Conf Files in Yeastar S-Series VoIP PBX

Edit custom config file extensions_custom.conf  in directory: /ysdisk/support/customcfg/

1) Add Alert-Info header for internal calls

  • add custom header context in file, and replace the name as you required.

[custom-header]

exten = add_internal_info, 1, Set(PJSIP_HEADER(add,Alert-Info)=<http://192.168.9.198>\;info=test)

  • Add variable CUSHEADER to get the header depending on the callerid in 'macro-realstexten' context

Copy all the content under [macro-realstexten] from /etc/asterisk/extensions.conf to extensions_custom.conf.

And the insert the sentence in red like the following:

[macro-realstexten]

....

exten = s,n,set(CDR(extfield4)=${PJSIPGETIP()})

exten = s,n,ExecIf($[${CALLERID(num)} = 3009]?Set(_CUSHEADER=b(custom-header^add_internal_info^1)))

exten = s,n,Gotoif($["${EXTENSION_STATE(${ARG1})}" = "INUSE"]?send-notify:judge-fork)

....

  • Add variable in Dial function in 'macro-realstexten' context

Based on the last step, insert the variable like the characters in red the following. It's better behind the deafault variable ${CALLERID(num)}

exten = s,n,Gotoif($[${GROUP_COUNT()}>1]?s-BUSY,1)

exten = s,n(dial),Dial(${ARG2},${RINGTIME_${PBXDIALNUM}},${ARG3}b(local_add_diversion,add_diversion,1(${SRCTRUNKNAME},${PBXDIALNUM},${CALLERID(num)}))${CUSHEADER}${RINGTONE}${MEETMEING},,${RINGINGPRIORITY_${PBXDIALNUM}})

exten = s,n,Gotoif(${LEN(${CONFER_INVITER})}>1?1-out,1)

  • Save the extensions_custom.conf, and Save & Apply any change on the web interface. To let the whole modification take effect.

2) Add Alert-Info header for calls from Ring Group

  • Add custom header context in file, and replace the name as you required.

[custom-header]

exten = add_ringgroup_info, 1, Set(PJSIP_HEADER(add,Alert-Info)=<http://192.168.9.198>\;info=test)

  • Use variable CUSHEADER to get the header and add header in Dial function.

Copy all the content under [ringgroup_6200] from /etc/asterisk/extensions.conf to extensions_custom.conf. The ring group dialplan context name has format "ringgroup_XXX", XXX is the ring group number.

For example the following context is for ring group 6200.

Insert the sentence and variable in red  regarding to the original dialplan.

[ringgroup_6200]

....

exten = 6200,n,Set(CDR(ringtype)=ringall)
exten = 6200,n,Set(_CUSHEADER=b(custom-header^add_ringgroup_info^1))
exten = 6200,n,Set(RINGTYPE=ringall)
exten = 6200,n,Dial(${DIALPARAM_OF_EXTEN3007}&${DIALPARAM_OF_EXTEN3008},60,TtKkXx${RINGTONE}${CUSHEADER})

exten = 6200,n,Goto(always-Hangup,h,1)

....

  • Save the extensions_custom.conf, and Save & Apply any change on the web interface. To let the whole modification take effect.

You can refer to the extensions_custom.conf file in attachment.

 

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.