Dialling a Dynamic extension number from value captured and processed from DTMF

Hello

Sorry if this has been already answered but I could not find something similar to my issue by searching here.

I am trying to create a call flow where:

  1. The inbound call is sent to a Dynamic Route
  2. 6 Digit DTMF is captured (Sales Quotation Number) in a variable named: DYNROUTE_quote_id and matched against an API which returns an extension number of the agent who is dealing with the quotation.
  3. The Result is saved into a variable in Dynamic Route Saved variable section named: DYNROUTE_agent_ext
  4. Then the call is sent to a Custom destination with target: from-internal,${DYNROUTE_agent_ext},1

However this is failing with the following output:

== Using SIP RTP Audio TOS bits 184
== Using SIP RTP Audio TOS bits 184 in TCLASS field.
== Using SIP RTP Audio CoS mark 5
– Executing [[email protected]:1] NoOp(“PJSIP/100001-0000001e”, “Running miscapp 1: Test Dynamic Route”) in new stack
– Executing [[email protected]:2] Macro(“PJSIP/100001-0000001e”, “user-callerid,”) in new stack
– Executing [[email protected]:1] Set(“PJSIP/100001-0000001e”, “TOUCH_MONITOR=1675734198.30”) in new stack
– Executing [[email protected]:2] Set(“PJSIP/100001-0000001e”, “CHANCONTEXT=”) in new stack
– Executing [[email protected]:3] Set(“PJSIP/100001-0000001e”, “CHANCONTEXT=”) in new stack
– Executing [[email protected]:4] Set(“PJSIP/100001-0000001e”, “CHANEXTENCONTEXT=100001-0000001e”) in new stack
– Executing [[email protected]:5] Set(“PJSIP/100001-0000001e”, “CHANEXTEN=100001-0000001e”) in new stack
– Executing [[email protected]:6] Set(“PJSIP/100001-0000001e”, “CALLERID(number)=100001”) in new stack
– Executing [[email protected]:7] Set(“PJSIP/100001-0000001e”, “AMPUSER=100001”) in new stack
– Executing [[email protected]:8] Set(“PJSIP/100001-0000001e”, “HOTDESCKCHAN=100001-0000001e”) in new stack
– Executing [[email protected]:9] Set(“PJSIP/100001-0000001e”, “HOTDESKEXTEN=100001”) in new stack
– Executing [[email protected]:10] Set(“PJSIP/100001-0000001e”, “HOTDESKCALL=0”) in new stack
– Executing [[email protected]:11] ExecIf(“PJSIP/100001-0000001e”, “0?Set(HOTDESKCALL=1)”) in new stack
– Executing [[email protected]:12] ExecIf(“PJSIP/100001-0000001e”, “0?Set(CALLERID(name)=)”) in new stack
– Executing [[email protected]:13] GotoIf(“PJSIP/100001-0000001e”, “0?report”) in new stack
– Executing [[email protected]:14] ExecIf(“PJSIP/100001-0000001e”, “1?Set(REALCALLERIDNUM=100001)”) in new stack
– Executing [[email protected]:15] Set(“PJSIP/100001-0000001e”, “AMPUSER=100001”) in new stack
– Executing [[email protected]:16] GotoIf(“PJSIP/100001-0000001e”, “0?limit”) in new stack
– Executing [[email protected]:17] Set(“PJSIP/100001-0000001e”, “AMPUSERCIDNAME=User-1”) in new stack
– Executing [[email protected]:18] ExecIf(“PJSIP/100001-0000001e”, “0?Set(__CIDMASQUERADING=TRUE)”) in new stack
– Executing [[email protected]:19] GotoIf(“PJSIP/100001-0000001e”, “0?report”) in new stack
– Executing [[email protected]:20] Set(“PJSIP/100001-0000001e”, “AMPUSERCID=100001”) in new stack
– Executing [[email protected]:21] Set(“PJSIP/100001-0000001e”, “__DIAL_OPTIONS=HhTtr”) in new stack
– Executing [[email protected]:22] Set(“PJSIP/100001-0000001e”, “CALLERID(all)=“User-1” <100001>”) in new stack
– Executing [[email protected]:23] ExecIf(“PJSIP/100001-0000001e”, “0?Set(CUSDIAL=)”) in new stack
– Executing [[email protected]:24] ExecIf(“PJSIP/100001-0000001e”, “0?Set(CALLERID(all)=“User-1” <100001>)”) in new stack
– Executing [[email protected]:25] GotoIf(“PJSIP/100001-0000001e”, “0?limit”) in new stack
– Executing [[email protected]:26] ExecIf(“PJSIP/100001-0000001e”, “0?Set(GROUP(concurrency_limit)=100001)”) in new stack
– Executing [[email protected]:27] ExecIf(“PJSIP/100001-0000001e”, “0?Set(CHANNEL(language)=)”) in new stack
– Executing [[email protected]:28] NoOp(“PJSIP/100001-0000001e”, “Macro Depth is 1”) in new stack
– Executing [[email protected]:29] GotoIf(“PJSIP/100001-0000001e”, “1?report2:macroerror”) in new stack
– Goto (macro-user-callerid,s,30)
– Executing [[email protected]:30] GotoIf(“PJSIP/100001-0000001e”, “0?continue”) in new stack
– Executing [[email protected]:31] ExecIf(“PJSIP/100001-0000001e”, “1?Set(__CALLEE_ACCOUNCODE=)”) in new stack
– Executing [[email protected]:32] Set(“PJSIP/100001-0000001e”, “__TTL=64”) in new stack
– Executing [[email protected]:33] GotoIf(“PJSIP/100001-0000001e”, “1?continue”) in new stack
– Goto (macro-user-callerid,s,49)
– Executing [[email protected]:49] Set(“PJSIP/100001-0000001e”, “CALLERID(number)=100001”) in new stack
– Executing [[email protected]:50] Set(“PJSIP/100001-0000001e”, “CALLERID(name)=User-1”) in new stack
– Executing [[email protected]:51] GotoIf(“PJSIP/100001-0000001e”, “0?cnum”) in new stack
– Executing [[email protected]:52] Set(“PJSIP/100001-0000001e”, “CDR(cnam)=User-1”) in new stack
– Executing [[email protected]:53] Set(“PJSIP/100001-0000001e”, “CDR(cnum)=100001”) in new stack
– Executing [[email protected]:54] Set(“PJSIP/100001-0000001e”, “CHANNEL(language)=en_GB”) in new stack
– Executing [[email protected]:3] Goto(“PJSIP/100001-0000001e”, “dynroute-1,s,1”) in new stack
– Goto (dynroute-1,s,1)
– Executing [[email protected]:1] Set(“PJSIP/100001-0000001e”, “__DYNROUTE_RETRIES=0”) in new stack
– Executing [[email protected]:2] Read(“PJSIP/100001-0000001e”, “dtmfinput,6,5”) in new stack
– Accepting a maximum of 6 digits.
> 0x7f3b10016a40 – Strict RTP learning after remote address set to: 192.168.50.133:37921
> 0x7f3b10016a40 – Strict RTP switching to RTP target address 192.168.50.133:37921 as source
– User entered ‘500001’
– Executing [[email protected]:3] Set(“PJSIP/100001-0000001e”, “__DYNROUTE_DYNROUTE_quote_id=500001”) in new stack
– Executing [[email protected]:4] Set(“PJSIP/100001-0000001e”, “dynroute=”) in new stack
– Executing [[email protected]:5] Set(“PJSIP/100001-0000001e”, “dynroute=500001”) in new stack
– Executing [[email protected]:6] Set(“PJSIP/100001-0000001e”, “dynroute=500001”) in new stack
– Executing [[email protected]:7] Set(“PJSIP/100001-0000001e”, “__DYNROUTE_DYNROUTE_agent_ext=500001”) in new stack
– Executing [[email protected]:8] GotoIf(“PJSIP/100001-0000001e”, “0?dynroute-1,1,1”) in new stack
– Executing [[email protected]:9] Goto(“PJSIP/100001-0000001e”, “dynroute-1,1,1”) in new stack
– Goto (dynroute-1,1,1)
– Executing [[email protected]:1] Goto(“PJSIP/100001-0000001e”, “from-internal,1”) in new stack
– Goto (from-internal,1,1)
[2023-02-07 01:43:22] WARNING[10295][C-0000001f]: pbx.c:4513 __ast_pbx_run: Channel ‘PJSIP/100001-0000001e’ sent to invalid extension but no invalid handler: context,exten,priority=from-internal,1,1
– Executing [[email protected]:1] Macro(“PJSIP/100001-0000001e”, “hangupcall”) in new stack
– Executing [[email protected]:1] GotoIf(“PJSIP/100001-0000001e”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,3)
– Executing [[email protected]:3] ExecIf(“PJSIP/100001-0000001e”, “0?Set(CDR(recordingfile)=)”) in new stack
– Executing [[email protected]:4] Hangup(“PJSIP/100001-0000001e”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘PJSIP/100001-0000001e’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on ‘PJSIP/100001-0000001e’

Looks like for some reason the variable is putting a null value to the dialplan. I will be very grateful if someone could kindly point me to the right direction to achieve this. Many thanks in Advance.

The agent_ext seems to also be “500001”. Is that a valid extension?

Hi yes. 500001 is a virtual extension with Voicemail enabled for test.

Hello, I think I have figured it out. I kind of misunderstood the tooltip:

“This is available as [xxx] in the query/lookup where xxx is the name of the variable you specify here. To use the variable in the dialplan (e.g. custom applicaitons) it is necessary to prefix it with DYNROUTE_ e.g. DYNROUTE_xxx”

I have now renamed the result variable to: agent_ext (previously was DYNROUTE_agent_ext)

and in the custom destination set the target as: ext-local,${DYNROUTE_agent_ext},1

Seems to be working!!!

1 Like

Good stuff. There is a method in this post where you can use a second Dynroute to validate that the API returns a valid extension number: Dynamic Routes - Extension Check - #2 by lgaetz

${DIALPLAN_EXISTS(ext-local,${DYNROUTE_agent_ext},1)}

The second dynroute could then branch call to the extension or to a generic destination.

Thank you kind Sir!

1 Like

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