Haw to execute agi on inbound calls from a did

Hi,

I need to execute an AGI script in one of the 6 inbound did rules. The call goes across different time conditions, and finally finishes ringing different groups depending on the time.

I need to find the exact context or macro prior to dial aplication, to execute an agi script. This script is able to make a query to a database and then, the name of the caller, is shown on the telephone.

The script works perfectly.

Can anyone help me please?

Thanks!

You could find the [ext-did-000N] in /etc/asterisk/extensions_additional.conf that contains your DID and add selectivity to the AGI script in [ext-did-000n-custom] as all DID’s in that context share the same “custom” context

Thank you dicko.

I’ve reading the extensions_additional.conf, and I found the part that dial the phone number, and I write two lines for executing it. It works, but it would be better to put them in macro-dial, but I can’t find it. Does it really exist? Should be perfect to execute it in every inboubd call on extensions:

exten => 605,1,Macro(user-callerid,)
exten => 605,n,Macro(blkvm-setifempty,)
exten => 605,n,GotoIf($[“${GOSUB_RETVAL}” = “TRUE”]?skipov)
exten => 605,n,Macro(blkvm-set,reset)
exten => 605,n,Set(__NODEST=)
exten => 605,n(skipov),Set(RRNODEST=${NODEST})
exten => 605,n(skipvmblk),Set(__NODEST=${EXTEN})
exten => 605,n,GosubIf($[${DB_EXISTS(RINGGROUP/605/changecid)} = 1 & “${DB(RINGGROUP/605/changecid)}” != “default” & “${DB(RINGGROUP/605/changecid)}” != “”]?sub-rgsetc$
exten => 605,n,Gosub(sub-record-check,s,1(rg,605,dontcare))
exten => 605,n,Set(RingGroupMethod=memoryhunt)
> exten => 605,n,AGI(/usr/local/bin/set_name_incoming_timeout.sh)
> exten => 605,n,NoOp(================ AGI IT’S BEEN EXECUTED====================)
exten => 605,n(DIALGRP),Macro(dial,50,m(default)${REPLACE(DIAL_OPTIONS,r)},405)
exten => 605,n,Gosub(sub-record-cancel,s,1())

Best regards.

You said inbound slls macrodial is not called for them

So, what macro is the one in theese lines? AGI script works in this example:

exten => 605,n,Gosub(sub-record-check,s,1(rg,605,dontcare))
exten => 605,n,Set(RingGroupMethod=memoryhunt)
exten => 605,n,AGI(/usr/local/bin/set_name_incoming_timeout.sh)
exten => 605,n,NoOp(================ AGI IT’S BEEN EXECUTED====================)
exten => 605,n(DIALGRP),Macro(dial,50,m(default)${REPLACE(DIAL_OPTIONS,r)},405)
exten => 605,n,Gosub(sub-record-cancel,s,1())

Regards

Read the [macro-dial] context in /etc/asterisk/extensions.conf, it is not directly tied to any incoming call however only any derivative routing that might dial extensions.