AGI Variable DEXTEN not being passed to custom module

change ${DIALEDPEERNUMBER} to ${DB(DEVICE/${DIALEDPEERNUMBER}/user)}

2 Likes

@tm1000 Whow, I can’t say thank you enough for helping me through this, way deeper than my current Asterisk/FreePBX knowledge level!

Here is my successfull dump on FreePBX 14 + Ast 11

Do you see any harm in Ast 13? I can try that easily anyway w/ asterisk-version-switch, one of the many great features of the official Distro!

If you want to look through more of the code to improve it, feel free, but im concered with results, and its working!

@lgaetz I will discuss/learn to apply correct license asap.

voip2*CLI>
    --  Feature Found: bsurvey1 exten: bsurvey1
    -- Executing [s@macro-bsurvey:1] DumpChan("SIP/2041-00000085", "") in new stack

Dumping Info For Channel: SIP/2041-00000085:
================================================================================
Info:
Name=               SIP/2041-00000085
Type=               SIP
UniqueID=           1490142435.7483
LinkedID=           1490142434.7426
CallerIDNum=        2041
CallerIDName=       John Smith
ConnectedLineIDNum= +12155555555
ConnectedLineIDName=M0:TK-SAINT ALBANS NY
DNIDDigits=         (N/A)
RDNIS=              (N/A)
Parkinglot=         default
Language=           en
State=              Up (6)
Rings=              0
NativeFormat=       (ulaw)
WriteFormat=        ulaw
ReadFormat=         ulaw
RawWriteFormat=     ulaw
RawReadFormat=      ulaw
WriteTranscode=     No
ReadTranscode=      No
1stFileDescriptor=  42
Framesin=           469
Framesout=          455
TimetoHangup=       0
ElapsedTime=        0h0m14s
DirectBridge=       <none>
IndirectBridge=     <none>
Context=            macro-bsurvey
Extension=          s
Priority=           1
CallGroup=
PickupGroup=
Application=        DumpChan
Data=               (Empty)
Blocking_in=        (Not Blocking)

Variables:
MACRO_DEPTH=1
ARG1=1
MACRO_PRIORITY=1
MACRO_CONTEXT=macro-dial
MACRO_EXTEN=s
DYNAMIC_FEATURENAME=bsurvey1
DYNAMIC_PEERNAME=Local/847@from-queue-00000e58;2
BRIDGEPEER=Local/847@from-queue-00000e58;2
SIPADDHEADER03=
SIPADDHEADER01=
SIPADDHEADER02=
SIPADDHEADER04=
GOSUB_RETVAL=
FORWARD_CONTEXT=from-internal
CFIGNORE=
MACRO_RESULT=
sipkey=
SIPHEADERKEYS=
DIALEDPEERNUMBER=2041
[email protected]:5060
CWIGNORE=
KEEPCID=TRUE
SAVEDCIDNAME=TK-SAINT ALBANS NY
REC_STATUS=RECORDING
RECORD_ID=Local/847@from-queue-00000e58;2
MIXMON_ID=0x7fa27812c8d0
CALLFILENAME=external-847-613-20170321-202714-1490142435.7480
REC_POLICY_MODE=FORCE
FROMQ=true
MOHCLASS=classical-piano
NODEST=613
QUEUEWAIT=1490142435
TTL=64
CALLEE_ACCOUNCODE=
REALCALLERIDNUM=+12155555555
CALLINGNUMPRES_SV=allowed_not_screened
CALLINGNAMEPRES_SV=allowed_not_screened
REVERSAL_REJECT=FALSE
FROM_DID=2675555555
MON_FMT=wav
TIMESTR=20170321-202714
YEAR=2017
MONTH=03
DAY=21
DIRECTION=INBOUND
================================================================================
    -- Executing [s@macro-bsurvey:2] ChannelRedirect("SIP/2041-00000085", "Local/847@from-queue-00000e58;2,bsurvey,1,1") in new stack
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('HANGUP',{ts '2017-03-21 20:27:29.240055'},'John Smith','2041','2041','','','s','bsurvey','SIP/2041-00000085','AppDial','(Outgoing Line)',3,'','1490142435.7483','1490142434.7426','','','')]
  == Spawn extension (bsurvey, 1, 1) exited non-zero on 'Local/847@from-queue-00000e58;2' in macro 'dial'
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('CHAN_END',{ts '2017-03-21 20:27:29.240629'},'John Smith','2041','2041','','','s','bsurvey','SIP/2041-00000085','AppDial','(Outgoing Line)',3,'','1490142435.7483','1490142434.7426','','','')]
  == Spawn extension (bsurvey, 1, 1) exited non-zero on 'Local/847@from-queue-00000e58;2'
    -- Executing [1@bsurvey:1] Set("Local/847@from-queue-00000e58;2", "bsurvey_name=support") in new stack
    -- Executing [1@bsurvey:2] Set("Local/847@from-queue-00000e58;2", "bsurvey_start=2017-03-21 20:27:15") in new stack
    -- Executing [1@bsurvey:3] Set("Local/847@from-queue-00000e58;2", "bsurvey_unqiueid=1490142435.7480") in new stack
    -- Executing [1@bsurvey:4] Set("Local/847@from-queue-00000e58;2", "bsurvey_agent=847") in new stack
    -- Executing [1@bsurvey:5] Set("Local/847@from-queue-00000e58;2", "bsurvey_aname_key=/AMPUSER/847/cidname=") in new stack
    -- Executing [1@bsurvey:6] Set("Local/847@from-queue-00000e58;2", "bsurvey_aname=") in new stack
    -- Executing [1@bsurvey:7] DumpChan("Local/847@from-queue-00000e58;2", "") in new stack

Dumping Info For Channel: Local/847@from-queue-00000e58;2:
================================================================================
Info:
Name=               Local/847@from-queue-00000e58;2
Type=               Local
UniqueID=           1490142435.7480
LinkedID=           1490142434.7426
CallerIDNum=        +12155555555
CallerIDName=       M0:TK-SAINT ALBANS NY
ConnectedLineIDNum= 2041
ConnectedLineIDName=John Smith
DNIDDigits=         (N/A)
RDNIS=              (N/A)
Parkinglot=
Language=           en
State=              Up (6)
Rings=              0
NativeFormat=       (ulaw)
WriteFormat=        ulaw
ReadFormat=         ulaw
RawWriteFormat=     ulaw
RawReadFormat=      ulaw
WriteTranscode=     No
ReadTranscode=      No
1stFileDescriptor=  -1
Framesin=           464
Framesout=          450
TimetoHangup=       0
ElapsedTime=        0h0m14s
DirectBridge=       <none>
IndirectBridge=     <none>
Context=            bsurvey
Extension=          1
Priority=           7
CallGroup=
PickupGroup=
Application=        DumpChan
Data=               (Empty)
Blocking_in=        (Not Blocking)

Variables:
bsurvey_aname=
bsurvey_aname_key=/AMPUSER/847/cidname=
DB_RESULT=847
bsurvey_agent=847
bsurvey_unqiueid=1490142435.7480
bsurvey_start=2017-03-21 20:27:15
bsurvey_name=support
MACRO_DEPTH=0
DIALSTATUS=ANSWER
DYNAMIC_FEATURENAME=bsurvey1
DYNAMIC_PEERNAME=SIP/2041-00000085
[email protected]:5060
BRIDGEPEER=SIP/2041-00000085
SIPADDHEADER03=
SIPADDHEADER02=
SIPADDHEADER04=
SIPADDHEADER01=
DIALEDPEERNUMBER=2041
DIALEDPEERNAME=SIP/2041-00000085
DIALEDTIME=
ANSWEREDTIME=
ITER=2
EXTTOCALL=847
LOOPCNT=1
AGISTATUS=SUCCESS
ds=SIP/2041,,trM(auto-blkvm)
FILTERED_DIAL=847
CWIGNORE=
DIALSTATUS_CW=
KEEPCID=TRUE
SAVEDCIDNAME=TK-SAINT ALBANS NY
GOSUB_RETVAL=
REC_STATUS=RECORDING
RECORD_ID=Local/847@from-queue-00000e58;2
MIXMON_ID=0x7fa27812c8d0
LOCAL_MIXMON_ID=0x7fa27812c8d0
MIXMONITOR_FILENAME=/var/spool/asterisk/monitor/2017/03/21/external-847-613-20170321-202714-1490142435.7480.wav
CALLFILENAME=external-847-613-20170321-202714-1490142435.7480
REC_POLICY_MODE=FORCE
CALLEE=force
CALLTYPE=external
REC_POLICY_MODE_SAVE=NO
FROMEXTEN=613
CALLTYPE_OVERRIDE=external
QDOPTS=
RingGroupMethod=none
FROMQ=true
QAGENT=847
MOHCLASS=classical-piano
FORWARD_CONTEXT=block-cf
CFIGNORE=TRUE
NODEST=613
QUEUEWAIT=1490142435
TTL=64
CALLEE_ACCOUNCODE=
REALCALLERIDNUM=+12155555555
CALLINGNUMPRES_SV=allowed_not_screened
CALLINGNAMEPRES_SV=allowed_not_screened
REVERSAL_REJECT=FALSE
FROM_DID=2675555555
MON_FMT=wav
TIMESTR=20170321-202714
YEAR=2017
MONTH=03
DAY=21
DIRECTION=INBOUND
================================================================================
    -- Executing [1@bsurvey:8] AGI("Local/847@from-queue-00000e58;2", "bsurvey.php") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/bsurvey.php
    -- bsurvey.php: Starting New survey
    -- AGI Script Executing Application: (Set) Options: (bsurvey_agent_name=${DB(/AMPUSER/847/cidname)})
       > bsurvey.php: Running SQL Command SELECT a.*,b.`displayname` as dp FROM bsurvey as a left join recordings as b on b.id=a.`rec_id` WHERE a.`id` = '1'
       > bsurvey.php: Connected to MySQL database OK.
       > bsurvey.php: Selected database OK.
[2017-03-21 20:27:29] WARNING[25247][C-00000045]: file.c:701 ast_openstream_full: File Alt_SV_Announce does not exist in any format
       > bsurvey.php: Running SQL Command select `id` from survey.bsurvey_cdrs limit 0
    -- bsurvey.php: TABLE CREATED
       > bsurvey.php: Running SQL Command SELECT rec_id,bsurvey_id,b.filename as file,a.displayname,a.res_start,a.res_end FROM bsurvey_recs a left join recordings as b on a.rec_id= b.id where bsurvey_id='1' ORDER BY a.id
    -- bsurvey.php: Do questions
    -- bsurvey.php: REC Array
    -- bsurvey.php: (
    -- bsurvey.php:     [rec_id] => 65
    -- bsurvey.php:     [bsurvey_id] => 1
    -- bsurvey.php:     [file] => custom/alt_sv_q1
    -- bsurvey.php:     [displayname] => Call Satisfaction
    -- bsurvey.php:     [res_start] => 1
    -- bsurvey.php:     [res_end] => 5
    -- bsurvey.php: )
    -- bsurvey.php:
       > bsurvey.php: Running SQL Command insert into survey.bsurvey_cdrs(survey_name,question,res_start ,res_end,rec_file,unqiueid,
       > bsurvey.php:                   calldate,cid,answer,agent,agent_name) values
       > bsurvey.php:   ('support','Call Satisfaction','1','5','custom/alt_sv_q1','1490142435.7480',
       > bsurvey.php:                   '2017-03-21 20:27:15','','','847','John Smith')
       > bsurvey.php: Running SQL Command select id from survey.bsurvey_cdrs where survey_name='support' and  question = 'Call Satisfaction' and  unqiueid='1490142435.7480' and agent_name = 'John Smith'  limit 1
    -- <Local/847@from-queue-00000e58;2> Playing 'custom/alt_sv_q1.slin' (language 'en')
       > bsurvey.php: Running SQL Command update survey.bsurvey_cdrs set answer='5' where id=571320
    -- bsurvey.php: Do questions
    -- bsurvey.php: REC Array
    -- bsurvey.php: (
    -- bsurvey.php:     [rec_id] => 66
    -- bsurvey.php:     [bsurvey_id] => 1
    -- bsurvey.php:     [file] => custom/alt_sv_q2
    -- bsurvey.php:     [displayname] => Product Satisfaction
    -- bsurvey.php:     [res_start] => 1
    -- bsurvey.php:     [res_end] => 5
    -- bsurvey.php: )
    -- bsurvey.php:
       > bsurvey.php: Running SQL Command insert into survey.bsurvey_cdrs(survey_name,question,res_start ,res_end,rec_file,unqiueid,
       > bsurvey.php:                   calldate,cid,answer,agent,agent_name) values
       > bsurvey.php:   ('support','Product Satisfaction','1','5','custom/alt_sv_q2','1490142435.7480',
       > bsurvey.php:                   '2017-03-21 20:27:15','','','847','John Smith')
       > bsurvey.php: Running SQL Command select id from survey.bsurvey_cdrs where survey_name='support' and  question = 'Product Satisfaction' and  unqiueid='1490142435.7480' and agent_name = 'John Smith'  limit 1
    -- <Local/847@from-queue-00000e58;2> Playing 'custom/alt_sv_q2.slin' (language 'en')
       > bsurvey.php: Running SQL Command update survey.bsurvey_cdrs set answer='5' where id=571321
    -- bsurvey.php: Do questions
    -- bsurvey.php: REC
    -- <Local/847@from-queue-00000e58;2> Playing 'bsurvey-thanku.slin' (escape_digits=123456789) (sample_offset 0) (language 'en')
    -- <Local/847@from-queue-00000e58;2>AGI Script bsurvey.php completed, returning -1
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('HANGUP',{ts '2017-03-21 20:27:40.137376'},'M0:TK-SAINT ALBANS NY','+12155555555','+12155555555','','','1','bsurvey','Local/847@from-queue-00000e58;2','','',3,'','1490142435.7480','1490142434.7426','','','')]
    -- Executing [h@ext-queues:1] Macro("SIP/Digium_Test-00000084", "hangupcall,") in new stack
       > [INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,uniqueid,recordingfile) VALUES ({ ts '2017-03-21 20:27:15' },'"M0:TK-SAINT ALBANS NY" <+12155555555>','+12155555555','847','from-queue-exten-only','Local/847@from-queue-00000e58;2','SIP/2041-00000085','AGI','HANGUP',25,20,'ANSWERED',3,'1490142435.7480','external-847-613-20170321-202714-1490142435.7480.wav')]
    -- Executing [s@macro-hangupcall:1] ExecIf("SIP/Digium_Test-00000084", "0?Set(CDR(recordingfile)=.wav)") in new stack
    -- Executing [s@macro-hangupcall:2] GotoIf("SIP/Digium_Test-00000084", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,4)
    -- Executing [s@macro-hangupcall:4] ExecIf("SIP/Digium_Test-00000084", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:5] Hangup("SIP/Digium_Test-00000084", "") in new stack
  == Spawn extension (macro-hangupcall, s, 5) exited non-zero on 'SIP/Digium_Test-00000084' in macro 'hangupcall'
  == Spawn extension (ext-queues, h, 1) exited non-zero on 'SIP/Digium_Test-00000084'
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('BRIDGE_END',{ts '2017-03-21 20:27:40.137721'},'TK-SAINT ALBANS NY','+12155555555','+12155555555','','2675555555','613','ext-queues','SIP/Digium_Test-00000084','Queue','613,t,,,,,,,,',3,'','1490142434.7426','1490142434.7426','Local/847@from-queue-00000e58;1','','')]
  == MixMonitor close filestream (mixed)
  == End MixMonitor Recording Local/847@from-queue-00000e58;2
       > [INSERT INTO cdr (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,uniqueid,did,cnum,cnam) VALUES ({ ts '2017-03-21 20:27:14' },'"TK-SAINT ALBANS NY" <+12155555555>','+12155555555','613','ext-queues','SIP/Digium_Test-00000084','Local/847@from-queue-00000e58;1','Queue','613,t,,,,,,,,',26,26,'ANSWERED',3,'1490142434.7426','2675555555','+12155555555','TK-SAINT ALBANS NY')]
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('CHAN_END',{ts '2017-03-21 20:27:40.142187'},'M0:TK-SAINT ALBANS NY','+12155555555','+12155555555','','','1','bsurvey','Local/847@from-queue-00000e58;2','','',3,'','1490142435.7480','1490142434.7426','','','')]
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('HANGUP',{ts '2017-03-21 20:27:40.144464'},'John Smith','2041','','','','613','from-queue','Local/847@from-queue-00000e58;1','AppQueue','(Outgoing Line)',3,'','1490142435.7479','1490142434.7426','','','')]
  == Spawn extension (ext-queues, 613, 41) exited non-zero on 'SIP/Digium_Test-00000084'
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('CHAN_END',{ts '2017-03-21 20:27:40.144527'},'John Smith','2041','','','','613','from-queue','Local/847@from-queue-00000e58;1','AppQueue','(Outgoing Line)',3,'','1490142435.7479','1490142434.7426','','','')]
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('APP_END',{ts '2017-03-21 20:27:40.145670'},'TK-SAINT ALBANS NY','+12155555555','+12155555555','','2675555555','613','ext-queues','SIP/Digium_Test-00000084','Queue','613,t,,,,,,,,',3,'','1490142434.7426','1490142434.7426','','','')]
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('HANGUP',{ts '2017-03-21 20:27:40.145807'},'TK-SAINT ALBANS NY','+12155555555','+12155555555','','2675555555','613','ext-queues','SIP/Digium_Test-00000084','','',3,'','1490142434.7426','1490142434.7426','','','')]
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('CHAN_END',{ts '2017-03-21 20:27:40.146334'},'TK-SAINT ALBANS NY','+12155555555','+12155555555','','2675555555','613','ext-queues','SIP/Digium_Test-00000084','','',3,'','1490142434.7426','1490142434.7426','','','')]
       > [INSERT INTO cel (eventtype,eventtime,cid_name,cid_num,cid_ani,cid_rdnis,cid_dnid,exten,context,channame,appname,appdata,amaflags,accountcode,uniqueid,linkedid,peer,userdeftype,userfield) VALUES ('LINKEDID_END',{ts '2017-03-21 20:27:40.146356'},'TK-SAINT ALBANS NY','+12155555555','+12155555555','','2675555555','613','ext-queues','SIP/Digium_Test-00000084','','',3,'','1490142434.7426','1490142434.7426','','','')]
voip2*CLI>
Disconnected from Asterisk server
Asterisk cleanly ending (0).
Executing last minute cleanups
[root@voip2 ~]#

It should be fine.

Glad you got it working!!

Contributing this back to the community would be good payment for the help we all provided here! :slight_smile: Help doesn’t always have to come in the form of money and something like this the community would love, especially if it can be proven to be GPL.

Edit: it also looks like ${EXTTOCALL} is filled with the correct user as well

So ${DEXTEN} could be ${EXTTOCALL} or ${DB(DEVICE/${DIALEDPEERNUMBER}/user)}

either way will work.

2 Likes

It’s truly unfortunate to see the removal of the survey module from github without any explanation after we (the community) helped you fix it for free.

5 Likes

Wow this is a sad turn of events and people wonder why developers become bitter.

Whow, relax guys, I need to apply proper licensing before I put it back up and I’d like to re-confirm it with my boss. Just covering my ass because there are so many bitter people suing people in this country :frowning:

2 Likes