1
votes

I am using Asterisk and dot net to send out calls that will play a pre-recorded message. It has been suggested that I use the dial command in my dialplan. My dial plan

[cpc_sendcall]
exten => _X.,1,Set(CHANNEL(userfield)=${actionid})
same => n,NoOp(RecordCall: ${dorec})
same => n,GotoIf($[${dorec}=1]?record:norecord)
same => n(record),mixmonitor(${recfile}.gsm)
same => n(norecord),dial(SIP/${EXTEN}@${carrier},45,G(cpc_doamd,s,1))
same => n,hangup
same => n,CELGenUserEvent(CPC-Failed,${myactionid},HC:${HANGUPCAUSE},DS:${DIALSTATUS})

[cpc_doamd]
exten => s,1,answer
same => n,AMD
same => n,GotoIf($[${AMDSTATUS}=HUMAN]?humn:mach)
same => n(humn),CELGenUserEvent(CPC-LiveAnswer,${myactionid})
same => n,WaitForSilence(500)
same => n,NoOp(ProductLA: ${myproductla})
same => n,goto(${myproductla},s,1)
same => n,Hangup
same => n(mach),CELGenUserEvent(CPC-AnsweringMachine,${myactionid})
same => n,NoOp(ToneDigit: ${mytonedigit})
same => n,goto(cpc_tonevmdigit,${mytonedigit},1)
same => n,NoOp(ProductAM: ${myproductam})
same => n,goto(${myproductam},s,1)
same => n,Hangup

[cpc_tonevmdigit]
exten => _X,1,senddtmf(${EXTEN})
same => n,return
exten => 10,1,senddtmf(*)
same => n,return
exten => 11,1,senddtmf(#)
same => n,return
exten => 12,1,WaitForSilence(2000,1,120)
same => n,WaitForSilence(200,2,1)
same => n,return

and the originate command

Action: Originate
Channel: local/7062675733@cpc_sendcall
Exten: 7062675733
Context: gp_playintro
Async: 1
Priority: 1
Timeout: 60000
ActionID: GNE-1-1-1-0-0-1-7062675733-40304
Variable: assignmentid=ff830065-2419-4134-be89-36873d99e7c3,dorec=0,tonedigit=12,predigits=-1,postdigits=-1,playcompanygreeting=0,pin=-1,dosvr=0,playSurveyNotice=0,dolat=0,playlatnotice=0,playcompanytrailer=0,productam=gpstart,productla=gpstart,actionid=GNE-1-1-1-0-0-1-7062675733-40304,carrier=excel
CallerId: 4053084474
Account: G1

What I would like to know is this the correct way to make this call? How do I access the channel variables that I have set once the call is answered?

Thank you

1

1 Answers

1
votes

You must use a local channel when calling with sip. Once the channel has been hung up the vars are gone. You can get around this by using a local channel.

This is a good resource for doing just that:

https://blogs.reucon.com/asterisk-java/originate-using-asterisk-local-channels-566/