Route Inbound Number to a Custom Dialplan

hi Guys,

I have write a custom code with some agi as well and want to route an inbound number to goto that context to get in the custom dialplan but unfortunately I am unable to do it.

what I did so far:
create a custom destination with target: abc,s,1

and route the inbound number to this custom destination.

in extensions_custom.conf i have created the dialplan with context “abc”

but call goes to abc and then hangup immediately and this continues the loop until I hangup myself.

Your broad strokes are correct. We may be able to assist further if you provide the dialplan and a call trace via pastebin.
https://wiki.freepbx.org/display/SUP/Providing+Great+Debug#ProvidingGreatDebug-AsteriskLogs-PartII


  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Executing [13321234567@from-pstn-e164-us:1] Set("SIP/IN-Provider1-00000047", "CALLERID(number)=3329876543") in new stack
    -- Executing [13321234567@from-pstn-e164-us:2] Goto("SIP/IN-Provider1-00000047", "from-pstn,13321234567,1") in new stack
    -- Goto (from-pstn,13321234567,1)
    -- Executing [13321234567@from-pstn:1] Set("SIP/IN-Provider1-00000047", "__DIRECTION=INBOUND") in new stack
    -- Executing [13321234567@from-pstn:2] Gosub("SIP/IN-Provider1-00000047", "sub-record-check,s,1(in,13321234567,dontcare)") in new stack
    -- Executing [s@sub-record-check:1] GotoIf("SIP/IN-Provider1-00000047", "0?initialized") in new stack
    -- Executing [s@sub-record-check:2] Set("SIP/IN-Provider1-00000047", "__REC_STATUS=INITIALIZED") in new stack
    -- Executing [s@sub-record-check:3] Set("SIP/IN-Provider1-00000047", "NOW=1639677850") in new stack
    -- Executing [s@sub-record-check:4] Set("SIP/IN-Provider1-00000047", "__DAY=16") in new stack
    -- Executing [s@sub-record-check:5] Set("SIP/IN-Provider1-00000047", "__MONTH=12") in new stack
    -- Executing [s@sub-record-check:6] Set("SIP/IN-Provider1-00000047", "__YEAR=2021") in new stack
    -- Executing [s@sub-record-check:7] Set("SIP/IN-Provider1-00000047", "__TIMESTR=20211216-180410") in new stack
    -- Executing [s@sub-record-check:8] Set("SIP/IN-Provider1-00000047", "__FROMEXTEN=unknown") in new stack
    -- Executing [s@sub-record-check:9] Set("SIP/IN-Provider1-00000047", "__MON_FMT=wav") in new stack
    -- Executing [s@sub-record-check:10] NoOp("SIP/IN-Provider1-00000047", "Recordings initialized") in new stack
    -- Executing [s@sub-record-check:11] ExecIf("SIP/IN-Provider1-00000047", "0?Set(ARG3=dontcare)") in new stack
    -- Executing [s@sub-record-check:12] Set("SIP/IN-Provider1-00000047", "REC_POLICY_MODE_SAVE=") in new stack
    -- Executing [s@sub-record-check:13] ExecIf("SIP/IN-Provider1-00000047", "0?Set(REC_STATUS=NO)") in new stack
    -- Executing [s@sub-record-check:14] GotoIf("SIP/IN-Provider1-00000047", "2?checkaction") in new stack
    -- Goto (sub-record-check,s,17)
    -- Executing [s@sub-record-check:17] GotoIf("SIP/IN-Provider1-00000047", "1?sub-record-check,in,1") in new stack
    -- Goto (sub-record-check,in,1)
    -- Executing [in@sub-record-check:1] NoOp("SIP/IN-Provider1-00000047", "Inbound Recording Check to 13321234567") in new stack
    -- Executing [in@sub-record-check:2] Set("SIP/IN-Provider1-00000047", "FROMEXTEN=unknown") in new stack
    -- Executing [in@sub-record-check:3] ExecIf("SIP/IN-Provider1-00000047", "10?Set(FROMEXTEN=3329876543)") in new stack
    -- Executing [in@sub-record-check:4] Gosub("SIP/IN-Provider1-00000047", "recordcheck,1(dontcare,in,13321234567)") in new stack
    -- Executing [recordcheck@sub-record-check:1] NoOp("SIP/IN-Provider1-00000047", "Starting recording check against dontcare") in new stack
    -- Executing [recordcheck@sub-record-check:2] Goto("SIP/IN-Provider1-00000047", "dontcare") in new stack
    -- Goto (sub-record-check,recordcheck,3)
    -- Executing [recordcheck@sub-record-check:3] Return("SIP/IN-Provider1-00000047", "") in new stack
    -- Executing [in@sub-record-check:5] Return("SIP/IN-Provider1-00000047", "") in new stack
    -- Executing [13321234567@from-pstn:3] Set("SIP/IN-Provider1-00000047", "CHANNEL(tonezone)=us") in new stack
    -- Executing [13321234567@from-pstn:4] Set("SIP/IN-Provider1-00000047", "__FROM_DID=13321234567") in new stack
    -- Executing [13321234567@from-pstn:5] Set("SIP/IN-Provider1-00000047", "returnhere=1") in new stack
    -- Executing [13321234567@from-pstn:6] Gosub("SIP/IN-Provider1-00000047", "app-blacklist-check,s,1()") in new stack
    -- Executing [s@app-blacklist-check:1] GotoIf("SIP/IN-Provider1-00000047", "0?blacklisted") in new stack
    -- Executing [s@app-blacklist-check:2] Set("SIP/IN-Provider1-00000047", "CALLED_BLACKLIST=1") in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/IN-Provider1-00000047", "") in new stack
    -- Executing [13321234567@from-pstn:7] Set("SIP/IN-Provider1-00000047", "CDR(did)=13321234567") in new stack
    -- Executing [13321234567@from-pstn:8] GotoIf("SIP/IN-Provider1-00000047", "0?") in new stack
    -- Executing [13321234567@from-pstn:9] ExecIf("SIP/IN-Provider1-00000047", "0 ?Set(CALLERID(name)=3329876543)") in new stack
    -- Executing [13321234567@from-pstn:10] Set("SIP/IN-Provider1-00000047", "__MOHCLASS=") in new stack
    -- Executing [13321234567@from-pstn:11] Set("SIP/IN-Provider1-00000047", "__REVERSAL_REJECT=FALSE") in new stack
    -- Executing [13321234567@from-pstn:12] GotoIf("SIP/IN-Provider1-00000047", "1?post-reverse-charge") in new stack
    -- Goto (from-pstn,13321234567,14)
    -- Executing [13321234567@from-pstn:14] NoOp("SIP/IN-Provider1-00000047", "") in new stack
    -- Executing [13321234567@from-pstn:15] Set("SIP/IN-Provider1-00000047", "__CALLINGNAMEPRES_SV=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:16] Set("SIP/IN-Provider1-00000047", "__CALLINGNUMPRES_SV=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:17] Set("SIP/IN-Provider1-00000047", "CALLERID(name-pres)=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:18] Set("SIP/IN-Provider1-00000047", "CALLERID(num-pres)=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:19] NoOp("SIP/IN-Provider1-00000047", "CallerID Entry Point") in new stack
    -- Executing [13321234567@from-pstn:20] Set("SIP/IN-Provider1-00000047", "__CRM_DIRECTION=INBOUND") in new stack
    -- Executing [13321234567@from-pstn:21] Set("SIP/IN-Provider1-00000047", "__CRM_SOURCE=3329876543") in new stack
    -- Executing [13321234567@from-pstn:22] Set("SIP/IN-Provider1-00000047", "__CRM_LINKEDID=1639677850.105") in new stack
    -- Executing [13321234567@from-pstn:23] AGI("SIP/IN-Provider1-00000047", "agi://127.0.0.1/sangomacrm.agi,true") in new stack
    -- <SIP/IN-Provider1-00000047>AGI Script agi://127.0.0.1/sangomacrm.agi completed, returning 0
    -- Executing [13321234567@from-pstn:24] ExecIf("SIP/IN-Provider1-00000047", "1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)") in new stack
    -- Executing [13321234567@from-pstn:25] Goto("SIP/IN-Provider1-00000047", "CUSTOM_INBOUND_INIT,s,1") in new stack
    -- Goto (CUSTOM_INBOUND_INIT,s,1)
    -- Executing [s@CUSTOM_INBOUND_INIT:1] Macro("SIP/IN-Provider1-00000047", "hangupcall,") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("SIP/IN-Provider1-00000047", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [s@macro-hangupcall:3] ExecIf("SIP/IN-Provider1-00000047", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:4] NoOp("SIP/IN-Provider1-00000047", " montior file= ") in new stack
    -- Executing [s@macro-hangupcall:5] GotoIf("SIP/IN-Provider1-00000047", "1?skipagi") in new stack
    -- Goto (macro-hangupcall,s,7)
    -- Executing [s@macro-hangupcall:7] Hangup("SIP/IN-Provider1-00000047", "") in new stack
  == Spawn extension (macro-hangupcall, s, 7) exited non-zero on 'SIP/IN-Provider1-00000047' in macro 'hangupcall'
  == Spawn extension (CUSTOM_INBOUND_INIT, s, 1) exited non-zero on 'SIP/IN-Provider1-00000047'
    -- Executing [h@CUSTOM_INBOUND_INIT:1] Macro("SIP/IN-Provider1-00000047", "hangupcall,") in new stack
    -- Executing [s@macro-hangupcall:1] GotoIf("SIP/IN-Provider1-00000047", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,3)
    -- Executing [s@macro-hangupcall:3] ExecIf("SIP/IN-Provider1-00000047", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:4] NoOp("SIP/IN-Provider1-00000047", " montior file= ") in new stack
    -- Executing [s@macro-hangupcall:5] GotoIf("SIP/IN-Provider1-00000047", "1?skipagi") in new stack
    -- Goto (macro-hangupcall,s,7)
    -- Executing [s@macro-hangupcall:7] Hangup("SIP/IN-Provider1-00000047", "") in new stack
  == Spawn extension (macro-hangupcall, s, 7) exited non-zero on 'SIP/IN-Provider1-00000047' in macro 'hangupcall'
  == Spawn extension (CUSTOM_INBOUND_INIT, h, 1) exited non-zero on 'SIP/IN-Provider1-00000047'
    -- SIP/IN-Provider1-00000047 Internal Gosub(crm-hangup,s,1) start
    -- Executing [s@crm-hangup:1] NoOp("SIP/IN-Provider1-00000047", "Sending Hangup to CRM") in new stack
    -- Executing [s@crm-hangup:2] NoOp("SIP/IN-Provider1-00000047", "HANGUP CAUSE: 16") in new stack
    -- Executing [s@crm-hangup:3] ExecIf("SIP/IN-Provider1-00000047", "0?Set(__CRM_VOICEMAIL=)") in new stack
    -- Executing [s@crm-hangup:4] NoOp("SIP/IN-Provider1-00000047", "MASTER CHANNEL: 1639677850.105 = 1639677850.105") in new stack
    -- Executing [s@crm-hangup:5] GotoIf("SIP/IN-Provider1-00000047", "0?return") in new stack
    -- Executing [s@crm-hangup:6] Set("SIP/IN-Provider1-00000047", "__CRM_HANGUP=1") in new stack
    -- Executing [s@crm-hangup:7] AGI("SIP/IN-Provider1-00000047", "agi://127.0.0.1/sangomacrm.agi") in new stack
    -- <SIP/IN-Provider1-00000047>AGI Script agi://127.0.0.1/sangomacrm.agi completed, returning 0
    -- Executing [s@crm-hangup:8] Return("SIP/IN-Provider1-00000047", "") in new stack
  == Spawn extension (CUSTOM_INBOUND_INIT, h, 1) exited non-zero on 'SIP/IN-Provider1-00000047'
    -- SIP/IN-Provider1-00000047 Internal Gosub(crm-hangup,s,1) complete GOSUB_RETVAL=
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5
    -- Executing [13321234567@from-pstn-e164-us:1] Set("SIP/IN-Provider2-00000048", "CALLERID(number)=3329876543") in new stack
    -- Executing [13321234567@from-pstn-e164-us:2] Goto("SIP/IN-Provider2-00000048", "from-pstn,13321234567,1") in new stack
    -- Goto (from-pstn,13321234567,1)
    -- Executing [13321234567@from-pstn:1] Set("SIP/IN-Provider2-00000048", "__DIRECTION=INBOUND") in new stack
    -- Executing [13321234567@from-pstn:2] Gosub("SIP/IN-Provider2-00000048", "sub-record-check,s,1(in,13321234567,dontcare)") in new stack
    -- Executing [s@sub-record-check:1] GotoIf("SIP/IN-Provider2-00000048", "0?initialized") in new stack
    -- Executing [s@sub-record-check:2] Set("SIP/IN-Provider2-00000048", "__REC_STATUS=INITIALIZED") in new stack
    -- Executing [s@sub-record-check:3] Set("SIP/IN-Provider2-00000048", "NOW=1639677857") in new stack
    -- Executing [s@sub-record-check:4] Set("SIP/IN-Provider2-00000048", "__DAY=16") in new stack
    -- Executing [s@sub-record-check:5] Set("SIP/IN-Provider2-00000048", "__MONTH=12") in new stack
    -- Executing [s@sub-record-check:6] Set("SIP/IN-Provider2-00000048", "__YEAR=2021") in new stack
    -- Executing [s@sub-record-check:7] Set("SIP/IN-Provider2-00000048", "__TIMESTR=20211216-180417") in new stack
    -- Executing [s@sub-record-check:8] Set("SIP/IN-Provider2-00000048", "__FROMEXTEN=unknown") in new stack
    -- Executing [s@sub-record-check:9] Set("SIP/IN-Provider2-00000048", "__MON_FMT=wav") in new stack
    -- Executing [s@sub-record-check:10] NoOp("SIP/IN-Provider2-00000048", "Recordings initialized") in new stack
    -- Executing [s@sub-record-check:11] ExecIf("SIP/IN-Provider2-00000048", "0?Set(ARG3=dontcare)") in new stack
    -- Executing [s@sub-record-check:12] Set("SIP/IN-Provider2-00000048", "REC_POLICY_MODE_SAVE=") in new stack
    -- Executing [s@sub-record-check:13] ExecIf("SIP/IN-Provider2-00000048", "0?Set(REC_STATUS=NO)") in new stack
    -- Executing [s@sub-record-check:14] GotoIf("SIP/IN-Provider2-00000048", "2?checkaction") in new stack
    -- Goto (sub-record-check,s,17)
    -- Executing [s@sub-record-check:17] GotoIf("SIP/IN-Provider2-00000048", "1?sub-record-check,in,1") in new stack
    -- Goto (sub-record-check,in,1)
    -- Executing [in@sub-record-check:1] NoOp("SIP/IN-Provider2-00000048", "Inbound Recording Check to 13321234567") in new stack
    -- Executing [in@sub-record-check:2] Set("SIP/IN-Provider2-00000048", "FROMEXTEN=unknown") in new stack
    -- Executing [in@sub-record-check:3] ExecIf("SIP/IN-Provider2-00000048", "10?Set(FROMEXTEN=3329876543)") in new stack
    -- Executing [in@sub-record-check:4] Gosub("SIP/IN-Provider2-00000048", "recordcheck,1(dontcare,in,13321234567)") in new stack
    -- Executing [recordcheck@sub-record-check:1] NoOp("SIP/IN-Provider2-00000048", "Starting recording check against dontcare") in new stack
    -- Executing [recordcheck@sub-record-check:2] Goto("SIP/IN-Provider2-00000048", "dontcare") in new stack
    -- Goto (sub-record-check,recordcheck,3)
    -- Executing [recordcheck@sub-record-check:3] Return("SIP/IN-Provider2-00000048", "") in new stack
    -- Executing [in@sub-record-check:5] Return("SIP/IN-Provider2-00000048", "") in new stack
    -- Executing [13321234567@from-pstn:3] Set("SIP/IN-Provider2-00000048", "CHANNEL(tonezone)=us") in new stack
    -- Executing [13321234567@from-pstn:4] Set("SIP/IN-Provider2-00000048", "__FROM_DID=13321234567") in new stack
    -- Executing [13321234567@from-pstn:5] Set("SIP/IN-Provider2-00000048", "returnhere=1") in new stack
    -- Executing [13321234567@from-pstn:6] Gosub("SIP/IN-Provider2-00000048", "app-blacklist-check,s,1()") in new stack
    -- Executing [s@app-blacklist-check:1] GotoIf("SIP/IN-Provider2-00000048", "0?blacklisted") in new stack
    -- Executing [s@app-blacklist-check:2] Set("SIP/IN-Provider2-00000048", "CALLED_BLACKLIST=1") in new stack
    -- Executing [s@app-blacklist-check:3] Return("SIP/IN-Provider2-00000048", "") in new stack
    -- Executing [13321234567@from-pstn:7] Set("SIP/IN-Provider2-00000048", "CDR(did)=13321234567") in new stack
    -- Executing [13321234567@from-pstn:8] GotoIf("SIP/IN-Provider2-00000048", "0?") in new stack
    -- Executing [13321234567@from-pstn:9] ExecIf("SIP/IN-Provider2-00000048", "0 ?Set(CALLERID(name)=3329876543)") in new stack
    -- Executing [13321234567@from-pstn:10] Set("SIP/IN-Provider2-00000048", "__MOHCLASS=") in new stack
    -- Executing [13321234567@from-pstn:11] Set("SIP/IN-Provider2-00000048", "__REVERSAL_REJECT=FALSE") in new stack
    -- Executing [13321234567@from-pstn:12] GotoIf("SIP/IN-Provider2-00000048", "1?post-reverse-charge") in new stack
    -- Goto (from-pstn,13321234567,14)
    -- Executing [13321234567@from-pstn:14] NoOp("SIP/IN-Provider2-00000048", "") in new stack
    -- Executing [13321234567@from-pstn:15] Set("SIP/IN-Provider2-00000048", "__CALLINGNAMEPRES_SV=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:16] Set("SIP/IN-Provider2-00000048", "__CALLINGNUMPRES_SV=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:17] Set("SIP/IN-Provider2-00000048", "CALLERID(name-pres)=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:18] Set("SIP/IN-Provider2-00000048", "CALLERID(num-pres)=allowed_not_screened") in new stack
    -- Executing [13321234567@from-pstn:19] NoOp("SIP/IN-Provider2-00000048", "CallerID Entry Point") in new stack
    -- Executing [13321234567@from-pstn:20] Set("SIP/IN-Provider2-00000048", "__CRM_DIRECTION=INBOUND") in new stack
    -- Executing [13321234567@from-pstn:21] Set("SIP/IN-Provider2-00000048", "__CRM_SOURCE=3329876543") in new stack
    -- Executing [13321234567@from-pstn:22] Set("SIP/IN-Provider2-00000048", "__CRM_LINKEDID=1639677857.106") in new stack
    -- Executing [13321234567@from-pstn:23] AGI("SIP/IN-Provider2-00000048", "agi://127.0.0.1/sangomacrm.agi,true") in new stack
    -- <SIP/IN-Provider2-00000048>AGI Script agi://127.0.0.1/sangomacrm.agi completed, returning 0
    -- Executing [13321234567@from-pstn:24] ExecIf("SIP/IN-Provider2-00000048", "1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)") in new stack

This is my Context: – Goto (CUSTOM_INBOUND_INIT,s,1)

Inbound call goes to Custom destination which goes to your dialplan, the first priority of which is a Macro hangup:

-- Executing [13321234567@from-pstn:25] Goto("SIP/IN-Provider1-00000047", "CUSTOM_INBOUND_INIT,s,1") in new stack
-- Goto (CUSTOM_INBOUND_INIT,s,1)
-- Executing [s@CUSTOM_INBOUND_INIT:1] Macro("SIP/IN-Provider1-00000047", "hangupcall,") in new stack

You’ve not shared your dialplan, but I bet you have a duplicate priority 1 with the hangup.

exten => s,1,NoOp(================ ${CONTEXT} ================)
exten => s,n,Set(__MSISDN=${CALLERID(num)})
exten => s,n,Set(__AGI_SERVER_IP=localhost)
exten => s,n,Set(__AGI_SERVER_PORT=7000)
exten => s,n,Set(__AGI_SERVER=agi://${AGI_SERVER_IP}:${AGI_SERVER_PORT})
exten => s,n,Goto(CUSTOM_INBOUND_PLAY_CONTENT,s,1)

exten => h,1,Hangup

This is the dialplan

Check again, or do a reload. Asterisk definitely thinks priority 1 of that context is Macro hangup.

what if we define priority 1 to “Goto” ?

I have checked it’s not even coming in the dialplan but hangup by freepbx system.

if it enters the dialplan it must have at least print the first line.

why do you have a hangup when you have a goto? If you are worried about a return, use a hangup ans the next priority.

exten => s,n,Hangup()

The contexts in the dialplan are case sensitive

@dicko thanks.

it worked with lowercase.

but now audio files are playing but I am not able to hear any sound from the files.

logs?

soxi /full/path/to/sound/file ?

 Playback("SIP/DIDFS1-0000003d", "/var/lib/asterisk/sounds/en/custom/question1") in new stack
    -- <SIP/DIDFS1-0000003d> Playing '/var/lib/asterisk/sounds/en/custom/question1.slin' (language 'en')

Input File : ‘/var/lib/asterisk/sounds/en/custom/question1.wav’
Channels : 1
Sample Rate : 8000
Precision : 16-bit
Duration : 00:00:16.62 = 132960 samples ~ 1246.5 CDDA sectors
File Size : 266k
Bit Rate : 128k
Sample Encoding: 16-bit Signed Integer PCM

lets get the logs from /var/log/asterisk/full because it has timestamps and check that the translated slin from wav file also takes 16 seconds to complete.

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