Monday, February 08, 2010

My Asterisk Links - passing variables

asterisk-gateway-interface-scripting-with-php
Asterisk+AGI+php
Asterisk+Detailed+Variable+List
Asterisk+variables
asterisk-channel-variables-and-the-asteriskagi-perl-module/
What is AGI?

I was able to pass variable from .php to dialplan, that is the number that SalesPitch.mobi needs to make the follow-up call, let's review the hard code:
/* as saved within the passvariables.php script itself */
//- essential parts of /var/lib/asterisk/agi-bin/passvariables.php
// lines 51 to 64
// create .PHP variable with a hard code phone number
$CLIENTNUMBER = '8005551212';
$SOMETEXT = '\"some text for swift to speak is thus\"'; // *
// speak a script identifying that we are in this file
write ("EXEC Swift \"pass variables dot p h p\"");
// speak the variable to be sure it works
write ("EXEC Swift \"$CLIENTNUMBER\""); // spoken as a billion number
write ("EXEC Swift \"$SOMETEXT\""); // spoken as complete string
// create DIALPLAN variable equal to .PHP variable
// this DIALPLAN variable is a Channel variable
write ("EXEC Set CLIENTNUMBER=$CLIENTNUMBER");
// * NB: ONLY THE FIRST WORD IN THE PHP VARIABLE IS GETTING PASSED * * *
write ("EXEC Set SOMETEXT=$SOMETEXT"); // *
// go to dialplan with DIALPLAN variables in tow
write ("EXEC Goto scene6|s|1");
// - essential parts of /etc/asterisk/extensions.conf [scene6|s|1]
/*
[scene6]
exten => s,1,Wait(1)
; identify this dialplan context
exten => s,2,SayDigits(66)
; go to this new context with "Channel" DIALPLAN variable in tow
exten => s,3,Goto(sceneTest,s,1)
; hangup if above not available
exten => s,n,Hangup()

[sceneTest]
exten => s,1,Wait(1)
; identify this dialplan context
exten => s,2,Swift(scene test)
; speak digits of DIALPLAN variable
; from passvariables.php
exten => s,3,SayDigits(${CLIENTNUMBER}) ; spoke in single digits
; * NB: Swift ONLY speaks first word of this DIALPLAN variable
; to be determined later how to pass a .PHP string as a variable
exten => s,4,Swift("${SOMETEXT}")
exten => s,n,Hangup()
exten => i,1,Playback(pbx-invalid)
exten => i,2,Goto(salespitch,s,1)
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup()
*/

No comments: