Custom Endpoint/Macro not working as expected

Hey all! If this has been answered I’m so sorry I’ve searched for hours to try to find something that works. This is a repost from the FreePBX forum as someone rightfully suggested I post here instead. We have a ticket platform we’d like calls sent to a queue to trigger an API via email. Here is what I have so far, the only thing missing is the DID the caller dialed or the Queue name they hit? I’ve manually added the queue and just plan to make a new custom extension per queue if needed, but I cannot fake which inbound route was used to get to the queue. Is there a variable I’m missing?

Both of these work, 9990002 is the test I was using to dump as many variables out I could think might help me… They unfortunately do not. :frowning:

exten => 9990001,1,NoOp(Entering user defined context [send-email] in extensions_custom.conf)

exten => 9990001,n,System(echo ‘{ “calleridname”: “${CALLERID(name)}”, “calleridnum”: “${CALLERID(number)}”, “queue”: “stinoc”}’ | mail -s ‘PBX-01’ ‘emailaddresshere’)

exten => 9990001,n,Congestion

exten => 9990002,1,NoOp(Entering user defined context [send-email] in extensions_custom.conf)

exten => 9990002,n,System(echo ‘{ “calleridname”: “${CALLERID(name)}”, “calleridnum”: “${CALLERID(number)}”, “queue”: “vienoc”}’ | mail -s ‘PBX-01’ ‘emailaddresshere’)

exten => 9990002,n,NoOp(ACCOUNTCODE=${ACCOUNTCODE})

exten => 9990002,n,NoOp(ANSWEREDTIME=${ANSWEREDTIME})

exten => 9990002,n,NoOp(BLINDTRANSFER=${BLINDTRANSFER})

exten => 9990002,n,NoOp(CALLERID=${CALLERID(all)})

exten => 9990002,n,NoOp(CALLERID(name)=${CALLERID(name)})

exten => 9990002,n,NoOp(CALLERID(number)=${CALLERID(number)})

exten => 9990002,n,NoOp(CALLINGPRES=${CALLINGPRES})

exten => 9990002,n,NoOp(CHANNEL=${CHANNEL})

exten => 9990002,n,NoOp(CONTEXT=${CONTEXT})

exten => 9990002,n,NoOp(DATETIME=${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)})

exten => 9990002,n,NoOp(DIALEDPEERNAME=${DIALEDPEERNAME})

exten => 9990002,n,NoOp(DIALEDPEERNUMBER=${DIALEDPEERNUMBER})

exten => 9990002,n,NoOp(DIALEDTIME=${DIALEDTIME})

exten => 9990002,n,NoOp(DIALSTATUS=${DIALSTATUS})

exten => 9990002,n,NoOp(DNID=${CALLERID(dnid)})

exten => 9990002,n,NoOp(EPOCH=${EPOCH})

exten => 9990002,n,NoOp(EXTEN=${EXTEN})

exten => 9990002,n,NoOp(HANGUPCAUSE=${HANGUPCAUSE})

exten => 9990002,n,NoOp(INVALID_EXTEN=${INVALID_EXTEN})

exten => 9990002,n,NoOp(LANGUAGE=${LANGUAGE()})

exten => 9990002,n,NoOp(MEETMESECS=${MEETMESECS})

exten => 9990002,n,NoOp(PRIORITY=${PRIORITY})

exten => 9990002,n,NoOp(RDNIS=${CALLERID(rdnis)}})

exten => 9990002,n,NoOp(SIPDOMAIN=${SIPDOMAIN})

exten => 9990002,n,NoOp(SIP_CODEC=${SIP_CODEC})

exten => 9990002,n,NoOp(SIPCALLID=${SIPCALLID})

exten => 9990002,n,NoOp(SIPUSERAGENT=${SIPUSERAGENT})

exten => 9990002,n,NoOp(TXTCIDNAME=${TXTCIDNAME})

exten => 9990002,n,NoOp(UNIQUEID=${UNIQUEID})

exten => 9990002,n,NoOp(TOUCH_MONITOR=${TOUCH_MONITOR})

exten => 9990002,n,NoOp(MACRO_CONTEXT=${MACRO_CONTEXT})

exten => 9990002,n,NoOp(MACRO_EXTEN=${MACRO_EXTEN})

exten => 9990002,n,NoOp(MACRO_PRIORITY=${MACRO_PRIORITY})

exten => 9990002,n,NoOp(CDRDID=${CDR(did)})

exten => 9990002,n,Congestion

Logs from these tests:

[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:1] NoOp(“Local/9990002@from-queue-000000a1;2”, “Entering user defined context [send-email] in extensions_custom.conf”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:2] System(“Local/9990002@from-queue-000000a1;2”, “echo ‘{ “calleridname”: “redacted KARA”, “calleridnum”: “redacted”, “queue”: “vienoc”}’ | mail -s ‘PBX-01’ ‘email’”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:3] NoOp(“Local/9990002@from-queue-000000a1;2”, “ACCOUNTCODE=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:4] NoOp(“Local/9990002@from-queue-000000a1;2”, “ANSWEREDTIME=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:5] NoOp(“Local/9990002@from-queue-000000a1;2”, “BLINDTRANSFER=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:6] NoOp(“Local/9990002@from-queue-000000a1;2”, “CALLERID=“VIE NOC:redeacted” ”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:7] NoOp(“Local/9990002@from-queue-000000a1;2”, “CALLERID(name)=VIE NOC:redacted”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:8] NoOp(“Local/9990002@from-queue-000000a1;2”, “CALLERID(number)=redacted”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:9] NoOp(“Local/9990002@from-queue-000000a1;2”, “CALLINGPRES=0”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:10] NoOp(“Local/9990002@from-queue-000000a1;2”, “CHANNEL=Local/9990002@from-queue-000000a1;2”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:11] NoOp(“Local/9990002@from-queue-000000a1;2”, “CONTEXT=from-internal”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:12] NoOp(“Local/9990002@from-queue-000000a1;2”, “DATETIME=08122023-23:51:49”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:13] NoOp(“Local/9990002@from-queue-000000a1;2”, “DIALEDPEERNAME=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:14] NoOp(“Local/9990002@from-queue-000000a1;2”, “DIALEDPEERNUMBER=9990002@from-queue/n”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:15] NoOp(“Local/9990002@from-queue-000000a1;2”, “DIALEDTIME=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:16] NoOp(“Local/9990002@from-queue-000000a1;2”, “DIALSTATUS=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:17] NoOp(“Local/9990002@from-queue-000000a1;2”, “DNID=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:18] NoOp(“Local/9990002@from-queue-000000a1;2”, “EPOCH=1702079509”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:19] NoOp(“Local/9990002@from-queue-000000a1;2”, “EXTEN=9990002”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:20] NoOp(“Local/9990002@from-queue-000000a1;2”, “HANGUPCAUSE=26”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:21] NoOp(“Local/9990002@from-queue-000000a1;2”, “INVALID_EXTEN=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:22] NoOp(“Local/9990002@from-queue-000000a1;2”, “LANGUAGE=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:23] NoOp(“Local/9990002@from-queue-000000a1;2”, “MEETMESECS=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:24] NoOp(“Local/9990002@from-queue-000000a1;2”, “PRIORITY=24”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:25] NoOp(“Local/9990002@from-queue-000000a1;2”, “RDNIS=}”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:26] NoOp(“Local/9990002@from-queue-000000a1;2”, “SIPDOMAIN=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:27] NoOp(“Local/9990002@from-queue-000000a1;2”, “SIP_CODEC=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:28] NoOp(“Local/9990002@from-queue-000000a1;2”, “SIPCALLID=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:29] NoOp(“Local/9990002@from-queue-000000a1;2”, “SIPUSERAGENT=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:30] NoOp(“Local/9990002@from-queue-000000a1;2”, “TXTCIDNAME=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:31] NoOp(“Local/9990002@from-queue-000000a1;2”, “UNIQUEID=1702079509.617”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:32] NoOp(“Local/9990002@from-queue-000000a1;2”, “TOUCH_MONITOR=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:33] NoOp(“Local/9990002@from-queue-000000a1;2”, “MACRO_CONTEXT=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:34] NoOp(“Local/9990002@from-queue-000000a1;2”, “MACRO_EXTEN=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:35] NoOp(“Local/9990002@from-queue-000000a1;2”, “MACRO_PRIORITY=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:36] NoOp(“Local/9990002@from-queue-000000a1;2”, “CDRDID=”) in new stack
[2023-12-08 23:51:49] VERBOSE[7360][C-00000011] pbx.c: Executing [9990002@from-internal:37] Congestion(“Local/9990002@from-queue-000000a1;2”, “”) in new stack

sorry but you need to use save this in a variable before you send the call to the queue

Set(DID-user-dialed=${EXTEN}) ; in te incomming context for DID
Set(Queue-user-dialed=XXX) ; in the context where you have your queue

Gotcha. Sounds like something not supported in FreePBX controlled environment.

hard to say as I have no knoleged about FreePBX
they may have it or not, you will have to ask on the FreePBX forum
but it is hard to belive that they do not have any funktion to save variables

I’m also no expert on FreePBX, but I think the first one is part of the standard FreePBX dialplan, but the variable name is different. The second one might well be similar.

try use this application in the dialplan to see what FreePBX are setting i diffrent Variables
https://docs.asterisk.org/Asterisk_18_Documentation/API_Documentation/Dialplan_Applications/DumpChan/

Looks like on the queue side of the call they aren’t sending much. I’ve asked the similar question FreePBX forum. It also doesn’t appear to take Variables set elsewhere and follow them to the queue? Odd.

VERBOSE[24894][C-00000020] pbx.c: Executing [9990002@from-internal:3] DumpChan(“Local/9990002@from-queue-00000148;2”, “”) in new stack
Dumping Info For Channel: Local/9990002@from-queue-00000148;2:
Name= Local/9990002@from-queue-00000148;2
Extension= 9990002
QAGENT=9990002
DIALEDPEERNUMBER=9990002@from-queue/n

This worked perfectly. Thank you!

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