PJSIP Auto Answer Headers on Transfer via AMI

We are currently adding support for Asterisk 12 + 13, including PJSIP, to our AMI application. One of the requirements we have is to auto answer initial origination callbacks, and some calls that are transferred. With Asterisk 1.8, 10, and 11 we did this via the SIPADDHEADERxx variable. For originations these variables would be set in the origination action. For transfers these variables would be set via VarSet actions prior to sending the transfer Action.

I have determine that we can use the following origination action for PJSIP, which works without issue:

action: Originate actionid: 1310932721_29#0.4266931641642656 variable: PJSIP_HEADER(add,Call-Info)=\;answer-after=0 variable: XMLNamespaceOrigDestExt=100 variable: PJSIP_HEADER(add,Alert-Info)=Ring Answer variable: PJSIP_HEADER(add,Alert-Info)=ring-answer variable: PJSIP_HEADER(add,Alert-Info)=<http://www.notused.com>\;info=alert-autoanswer\;delay=0 channel: PJSIP/300 priority: 1 exten: 100 timeout: 30000 async: true context: from-internal callerid: "300" <300>

Auto answer for transfer, on the other hand, does not work as expected. The following is a list of events I assumed would work based on my experience with the SIPADDHEADERxx variable, however none of the headers exist in the SIP invite after the Redirect action is initialized:

[code]action: SetVar
actionid: 1928204817_40#
variable: PJSIP_HEADER(add,Alert-Info)
channel: PJSIP/200-0000001a
value: Ring Answer

action: SetVar
actionid: 1928204817_41#
variable: PJSIP_HEADER(add,Alert-Info)
channel: PJSIP/200-0000001a
value: ring-answer

action: SetVar
actionid: 1928204817_42#
variable: PJSIP_HEADER(add,Alert-Info)
channel: PJSIP/200-0000001a
value: http://www.notused.com;info=alert-autoanswer;delay=0

action: SetVar
actionid: 1928204817_43#
variable: PJSIP_HEADER(add,Call-Info)
channel: PJSIP/200-0000001a
value: ;answer-after=0

action: Redirect
actionid: 1928204817_44#0.2539451841541377
context: from-internal
channel: PJSIP/200-0000001a
priority: 1
exten: 300[/code]

Could someone tell me if auto answer with PJSIP via the AMI is possible on a transfer, and if so what is the correct way to accomplish it.

Thank You,
Mike

2 Likes

I discovered that I was omitting the “__” prefix on the variable name, which would prevent the auto answer headers from propagating to the receiving channel on transfer. This is some thing that we do with the SIPADDHEADERxx variables. The problem is that when I send a SetVar action like the following

action: SetVar actionid: 1928204817_43# variable: __PJSIP_HEADER(add,Call-Info) channel: PJSIP/200-0000001a value: \;answer-after=0

I get an Error response with a message of “Variable not set”. I do not get the error response if I omit the “__” prefix.

These are the errors that I get in the Asterisk log:

[2015-05-13 13:30:03] ERROR[6152]: pbx.c:4427 ast_func_write: Function __PJSIP_HEADER not registered [2015-05-13 13:30:03] ERROR[6152]: pbx.c:4427 ast_func_write: Function __PJSIP_HEADER not registered [2015-05-13 13:30:03] ERROR[6152]: pbx.c:4427 ast_func_write: Function __PJSIP_HEADER not registered [2015-05-13 13:30:03] ERROR[6152]: pbx.c:4427 ast_func_write: Function __PJSIP_HEADER not registered

_ only works for variables, not for functions. Functions update the underlying data immediately and that then inherits according to the rules for that data.

David,

Thank you for the reply. I was afraid that might be the case. Do you know if there is another method that would allow me to do this, directly from the AMI, without the need for a custom context?

I was thinking about adding a custom channel variable, that I would be able to detect when the destination channel is created, and set the headers then, but I am not sure this would work as the invite may have already been sent out to the device.