Add custom header within ARI channels/{channelId}

Hello I am Asterisk newbie.

I want to originate call from MicroSIP soft phone to SIP trunk. When i call /channels/{id}, MicroSip shows dialog to accept call. In MicroSIP configuration i have turned on Auto answer on header “X-AUTOANSWER: TRUE”

Is there way how to send header to MicroSIP? I have tried put to variables this


You haven’t specified which SIP channel driver you are using, which will change the answer.

Why, especially as a newbie, are you using ARI for this? People have been doing click to call since long before ARI ever existed, and there must be many worked examples available.

I would originate to a local channel and use the officially documented, channel driver specific, APIs, to add the header.

Hi, first configuration was chan_sip. Current configuration is res_pjsip. Creating channel works, originate works, but auto answer not working…

The PJSIP_HEADER dialplan function[1] is used to set headers for PJSIP channels to send on the INVITE. It can be used the same way normal variables are.

[1] Asterisk 18 Function_PJSIP_HEADER - Asterisk Project - Asterisk Project Wiki

Thanks for advice. I have now PJSIP/6001 - MicroSIP phone and PJSIP/trunk.

exten => s,1,NoOp(setting-header)
same => n,Return

exten => 6001,1,NoOp(sip-6001)
same => n,Wait(1)
same => n,Dial(PJSIP/6001,b(add-header^s^1))

exten => _777XXXXXX,1,NoOp(make-outgoing-call)
same => n,Dial(PJSIP/${EXTEN}@trunk)

So when I call

Everything works, it will dial 777454545 and when phone answer, Asterisk connects to PJSIP/6001, header is properly set, so AutoAnswer works.

But I need first dial PJSIP/6001, set AutoAnswer header and after dial 777454545. When I call

MicroSIP don’t get AutoAnswer header, subroutine [add-header] is not executed.

You would need to set the PJSIP_HEADER dialplan function using the variables functionality in ARI.

You mean send in request body this ?

I tried this, but it have no effect.

It would be something like:

{'variables': {'PJSIP_HEADER(add,X-AUTOANSWER)': 'TRUE'}}
1 Like

Fantastic, it works.

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