Issue : Little bit trick in my syntax for incoming calls

exten => ${TEST_IN},1,NoOp(## Incoming Call from ${CALLERID(all)} ##)
 same => n,Verbose(Call start time: ${CDR(start)})
 same => n,Set(CDR(calldate)=${CDR(start)})
 same => n,Set(CDR(useragent)=${CALLERID(name)})
 same => n,Set(POSTE_EXT=${CALLERID(num)})
 same => n,Ringing()
 same => n,System(echo "--appel_sortant --- callerid : ${CALLERID(num)} ---- ${STRFTIME(${EPOCH},,%Y/%m/%d %H:%M:%S)} ----" >> /var/spool/asterisk/log/debug.txt)
 same => n,Set(REC_FILE_NAME=IN_${NOW}_${EXTEN}_${POSTE_EXT}.wav)
 same => n,Set(RETURNED_VALUE=${ODBC_LASTCALL(${CALLERID(num)})})
 same => n,MixMonitor(${REC_FILE_NAME},b V(1))
 same => n,GotoIf($[${ISNULL(${RETURNED_VALUE})}]?defaultExt:lastcalled) 
 same => n(defaultExt),Dial(PJSIP/114&PJSIP/115,30)
 same => n,Playback(ivr/REPONDEUR_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end) 
 same => n(lastcalled),Dial(PJSIP/${RETURNED_VALUE},30) 
 same => n,Playback(ivr/REPONDEUR_2)
 same => n,VoiceMail(${RETURNED_VALUE}@default) 
 same => n,Goto(end) 
 same => n(end),Hangup()

Hi @everyone,

I have a little tricky situation on this part of my syntax, when I make a call to the “TEST_IN”, I do not catch the extension 114 or 115 but in the CLI I have a “PJSIP/bel,30” who is execute. The variable RETURNED_VALUE send me a “bel” extension who do not exist in the pjsip.conf file.

 same => n,GotoIf($[${ISNULL(${RETURNED_VALUE})}]?defaultExt:lastcalled) 
 same => n(defaultExt),Dial(PJSIP/114&PJSIP/115,30)
 same => n,Playback(ivr/REPONDEUR_2)
 same => n,VoiceMail(${VM_TEST},s)
 same => n,Goto(end) 
 same => n(lastcalled),Dial(PJSIP/${RETURNED_VALUE},30) 
 same => n,Playback(ivr/REPONDEUR_2)
 same => n,VoiceMail(${RETURNED_VALUE}@default) 
 same => n,Goto(end) 
 same => n(end),Hangup()

I do not understand how this is happened. Do you know how to fix that ? I try in my cdr table to edit the colunn where I have the PJSIP/bel,30 (lastdata) by one of the extension what they supposed to call(PJSIP/114,30 or PJSIP/115,30). If someone can help me to understand what happen here.

Best regard,
Lordaker.

This is what I have in the CLI

 Setting global variable 'SIPDOMAIN' to ip_address
    -- Executing [042770677@from-external:1] NoOp("PJSIP/belgium-voip-000001b2", "## Incoming Call from "Arnold" <028992018> ##") in new stack
    -- Executing [042770677@from-external:2] Verbose("PJSIP/belgium-voip-000001b2", "Call start time: 2018-09-24 11:26:01") in new stack
Call start time: 2018-09-24 11:26:01
    -- Executing [042770677@from-external:3] Set("PJSIP/belgium-voip-000001b2", "CDR(calldate)=2018-09-24 11:26:01") in new stack
    -- Executing [042770677@from-external:4] Set("PJSIP/belgium-voip-000001b2", "CDR(useragent)=Arnold") in new stack
    -- Executing [042770677@from-external:5] Set("PJSIP/belgium-voip-000001b2", "POSTE_EXT=028992018") in new stack
    -- Executing [042770677@from-external:6] Ringing("PJSIP/belgium-voip-000001b2", "") in new stack
    -- Executing [042770677@from-external:7] System("PJSIP/belgium-voip-000001b2", "echo "--appel_sortant --- callerid : 028992018 ---- 2018/09/24 11:26:01 ----" >> /var/spool/asterisk/log/debug.txt") in new stack
    -- PJSIP/belgium-voip-000001b1 is ringing
    -- PJSIP/belgium-voip-000001b1 is ringing
    -- Executing [042770677@from-external:8] Set("PJSIP/belgium-voip-000001b2", "REC_FILE_NAME=IN__042770677_028992018.wav") in new stack
    -- Executing [042770677@from-external:9] Set("PJSIP/belgium-voip-000001b2", "RETURNED_VALUE=bel") in new stack
    -- Executing [042770677@from-external:10] MixMonitor("PJSIP/belgium-voip-000001b2", "IN__042770677_028992018.wav,b V(1)") in new stack
    -- Executing [042770677@from-external:11] GotoIf("PJSIP/belgium-voip-000001b2", "0?defaultExt:lastcalled") in new stack
    -- Goto (from-external,042770677,16)
    -- Executing [042770677@from-external:16] Dial("PJSIP/belgium-voip-000001b2", "PJSIP/bel,30") in new stack
[Sep 24 11:26:01] ERROR[30892]: chan_pjsip.c:2207 request: Unable to create PJSIP channel - endpoint 'bel' was not found
[Sep 24 11:26:01] WARNING[32162][C-000000f2]: app_dial.c:2527 dial_exec_full: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [042770677@from-external:17] Playback("PJSIP/belgium-voip-000001b2", "ivr/REPONDEUR_2") in new stack

I do not understand how the RETURNED_VALUE is “bel”. In my pjsip.conf file I have any endpoint “bel”.

You need to look at what’s in your database and what the query that your ODBC function is returning. Likely there is an error in your query or you are storing the wrong data.

Thank for your answer @johnkiniston
It is real in my database. I shall look a way to solve that.