PJSIP Auto Answer

I want to enable auto answer in from-internal for PJSIP endpoints. The last time I did this was for chan_sip endpoints, and all I did was add into /etc/asterisk/extensions_custom.conf:

[from-internal-custom]
exten => _1XX,1,SIPAddHeader(Alert-Info: Auto Answer)

This would be if I wanted all extensions in the 100 range to auto answer when they called each other.

What is the proper way to do this for PJSIP endpoints? I’ve seen

exten => s,n,GoSub(func-set-sipheader,s,1(Alert-Info,"Auto Answer"))

and

exten => s,n,Set(PJSIP_HEADER(add,Alert-info)=“Auto Answer”)

but I’m not sure if either is the correct way to do it.

Regardless of which SIP driver is in use, the best way would be to use the native FreePBX subroutines for adding headers. You pass two arguments to the subroutine, the fist is the name of the header, the second is the value, separated by a comma:

exten => s,n,GoSub(func-set-sipheader,s,1(X-Account-Code,90210))

I don’t recommend you add _1xx as an exten to from-internal-custom, I suggest you review this post about dialplan hooks: Hooking for fun and income

1 Like

No it wouldn’t, it would pertain to all extensions calling 1XX

edit:-

nevermind read @lgaetz reply

@lgaetz groovy I got it to work with

[macro-dialout-one-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-one-predial-hook in 
extensions_custom.conf)
exten => s,n,GoSub(func-set-sipheader,s,1(Alert-Info,Auto Answer))
exten => s,n,MacroExit

Can you take a look at this pastebin for the log of that call and tell me if it looks normal? In particular the lines:

[2022-02-15 15:09:54] WARNING[50112][C-00000046] ast_expr2.fl: ast_yyerror():  syntax error: syntax error, unexpected '<token>', expecting $end; Input: ""Auto Answer"" = "unset" & "PJSIP" = "SIP"

EDIT: made changes based on recommendations below.

Seeing double sets of quotes. Remove the quotes from around Auto Answer in your dialplan.

Perhaps try without quoting "Auto Answer"

That’s the magic. Thanks guys.

Not sure if this is helpful. But I found myself a lot of times trying to hack the dialplan, when there’s already a setting under advanced settings that does that.

If you specifically want to add a SIP Header, you can do it there as well:

2 Likes

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