How to put dial b function in AGI

Need to replace dialplan to AGI, someone help…plz.
exten => _87986499,1,Noop(SRC=${CALLERID(number)})
same => n,Noop(NAME=${CALLERID(name)})
same => n,NoOp(DST=${CALLERID(dnid)})
same => n,Dial(SIP/12345@TG1-VD1,60,b(from-sip^callee_handler^1))
same => n,Noop(SRC HANGUP)

exten => callee_handler,1,NoOp(add historyinfo for forword call)
same => n,SIPAddHeader(P-Asserted-Identity:sip:0XXXXXX@10.1.1.1,tel:0XXXXXX)
same => n,SIPAddHeader(History-Info:sip:87986499@10.1.1.1;index=1,sip:12345@10.1.1.1\;user=phone\;cause=302;index=1.1)
same => n,Return()

anyone plz give a hint…thanks

I don’t think that’s what AGI is for.

cause if i write in AGI:
channel.exec(“Dial”, SIP/12345@TG1-VD1,60,**b(from-sip^callee_handler^1));
i have to write callee_handler in dialplan, I don’t want to jump between them

You can’t. The ‘b’ option executes a subroutine in dialplan, that’s what it does.

ok
so ,i must write callee_handler in dialplan…?

Yes.

or is there any way can do sipaddheader in b channel?

I don’t remember chan_sip specifics. Someone else may remember the details or have input in that regard.

I can say that in AGI, you can’t execute things on another channel like ‘b’ does in Dial.

SipAddHeader questions should be considered academic, as you should not be using chan_sip. However, the way it works, it doesn’t need to be run on the B side channel, as it sets inheritable channel variables, which pass through to the B side when Dial creates the channel. That won’t work for the chan_pjsip equivalent.

Personally I wouldn’t make AGI my primary driver for control flow, and would use it to augment dialplan, not the other way round.

AGI EXEC can call Dial, so you could do this in an AGI. I have used Dial successfully via AGI EXEC, although I haven’t tried it using the ‘b’ option.

Anyway, here’s a simple dialplan example of setting custom headers on the outbound leg of a PJSIP Dial:

[outboundheaders]

exten => 12345,1,Verbose(Dialing with headers sub)
exten => 12345,n,SET(_MYSESSIONVAR=123456789)

exten => 12345,n,Dial(PJSIP/5551212@my_pj_peer,b(headers))
exten => 12345,n,Hangup()

exten => 12345,n(headers),NoOp(pre-dial channel setup)
exten => 12345,n,Set(PJSIP_HEADER(add,x-language)=en_US)
exten => 12345,n,Set(PJSIP_HEADER(add,x-session)=${MYSESSIONVAR})
exten => 12345,n,Return()

On Mon, Apr 15, 2024 at 8:41 AM david551 via Asterisk Community <notifications@asterisk.discoursemail.com> wrote:

david551
April 15

SipAddHeader questions should be considered academic, as you should not be using chan_sip. However, the way it works, it doesn’t need to be run on the B side channel, as it sets inheritable channel variables, which pass through to the B side when Dial creates the channel. That won’t work for the chan_pjsip equivalent.

Personally I wouldn’t make AGI my primary driver for control flow, and would use it to augment dialplan, not the other way round.


Visit Topic or reply to this email to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, click here.

yes,this is exactly what i do in dialplan sub

The OP is already using AGI EXEC:

i set all parameters(SRC,DST,ORGCALLEE) in AGI, and pass through it to callee_handler, this may help.

exten => callee_handler,1,NoOp(add historyinfo for forword call)
same => n,Set(PJSIP_HEADER(add,P-Asserted-Identity)=sip:${SRC}@${MIP},tel:${SRC})
same => n,Set(PJSIP_HEADER(add,History-Info)=tel:${ORGCALLEE};index=1,sip:${DST}@${MIP}\;user=phone\;cause=302;index=1.1)
same => n,Return()

The OP is already using AGI EXEC:

Yep, missed that!

  • Darrin