[asterisk-users] AGI: blocking script until playback complete
Greetings list, I've done AGI scripting before, but in the past I've always wanted control to be returned to the dialplan as soon as possible. However, today I have a scenario where I want the script to remain running during the playback of a file so that I can read DTMF at the end of playback. However, doing this: GET DATA en_welcome 5000 6 Results (correctly) in the following in the asterisk console: -- SIP/a.b.c.d-dc027b50 Playing 'en_welcome' (language 'en') But the AGI continues to run on after this point, not waiting for either the sound file to be played, nor for the expected 6 DTMF digits. Adding a simple 10 second sleep/wait to the AGI allows the sound file to be successfully played back. I'm sure I must be missing something very obvious, buy my google-fu is failing me this afternoon. Suggestions gratefully received :-) Thanks in advance. Kind regards, Chris -- This email is made from 100% recycled electrons -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
Try passing escape character GET DATA $filename $timeout $max_digits $escape_character Regards, Zohair Raza On Wed, Feb 22, 2012 at 6:40 PM, Chris Bagnall aster...@lists.minotaur.ccwrote: Greetings list, I've done AGI scripting before, but in the past I've always wanted control to be returned to the dialplan as soon as possible. However, today I have a scenario where I want the script to remain running during the playback of a file so that I can read DTMF at the end of playback. However, doing this: GET DATA en_welcome 5000 6 Results (correctly) in the following in the asterisk console: -- SIP/a.b.c.d-dc027b50 Playing 'en_welcome' (language 'en') But the AGI continues to run on after this point, not waiting for either the sound file to be played, nor for the expected 6 DTMF digits. Adding a simple 10 second sleep/wait to the AGI allows the sound file to be successfully played back. I'm sure I must be missing something very obvious, buy my google-fu is failing me this afternoon. Suggestions gratefully received :-) Thanks in advance. Kind regards, Chris -- This email is made from 100% recycled electrons -- __**__**_ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/**mailman/listinfo/asterisk-**usershttp://lists.digium.com/mailman/listinfo/asterisk-users -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
You don't state the Asterisk version you are running, but personal experience tells me you'd better invest in some Rogaine if you're depending on the built-in stuff from AGI for DTMF input. I have personally wasted weeks trying it. From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Zohair Raza Sent: Wednesday, February 22, 2012 8:50 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] AGI: blocking script until playback complete Try passing escape character GET DATA $filename $timeout $max_digits $escape_character Regards, Zohair Raza On Wed, Feb 22, 2012 at 6:40 PM, Chris Bagnall aster...@lists.minotaur.cc wrote: Greetings list, I've done AGI scripting before, but in the past I've always wanted control to be returned to the dialplan as soon as possible. However, today I have a scenario where I want the script to remain running during the playback of a file so that I can read DTMF at the end of playback. However, doing this: GET DATA en_welcome 5000 6 Results (correctly) in the following in the asterisk console: -- SIP/a.b.c.d-dc027b50 Playing 'en_welcome' (language 'en') But the AGI continues to run on after this point, not waiting for either the sound file to be played, nor for the expected 6 DTMF digits. Adding a simple 10 second sleep/wait to the AGI allows the sound file to be successfully played back. I'm sure I must be missing something very obvious, buy my google-fu is failing me this afternoon. Suggestions gratefully received :-) Thanks in advance. Kind regards, Chris -- This email is made from 100% recycled electrons -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
On 22/2/12 2:55 pm, Danny Nicholas wrote: You don't state the Asterisk version you are running, but personal experience tells me you'd better invest in some Rogaine if you're depending on the built-in stuff from AGI for DTMF input. I have personally wasted weeks trying it. Sorry, should have said, latest 1.4 release. Care to elaborate a little on the issues you found when you tried it? Kind regards, Chris -- This email is made from 100% recycled electrons -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
On 22/2/12 2:50 pm, Zohair Raza wrote: Try passing escape character GET DATA $filename $timeout $max_digits $escape_character Not sure I follow - according to the docs, there is no parameter $escape_character The problem seems to be that GET DATA returns control to the script before the audio file has even played, let alone any DTMF tones have been entered. I would have expected script execution to be blocked until the result from GET DATA was available. Kind regards, Chris -- This email is made from 100% recycled electrons -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
Are you reading STDIN to initialize your AGI? If not Asterisk may ignore your AGI commands. I recommend using one of the many AGI libs out there. -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Chris Bagnall Sent: Wednesday, February 22, 2012 10:20 AM To: asterisk-users@lists.digium.com Subject: Re: [asterisk-users] AGI: blocking script until playback complete On 22/2/12 2:50 pm, Zohair Raza wrote: Try passing escape character GET DATA $filename $timeout $max_digits $escape_character Not sure I follow - according to the docs, there is no parameter $escape_character The problem seems to be that GET DATA returns control to the script before the audio file has even played, let alone any DTMF tones have been entered. I would have expected script execution to be blocked until the result from GET DATA was available. Kind regards, Chris -- This email is made from 100% recycled electrons -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
Chris Bagnall wrote: Greetings list, I've done AGI scripting before, but in the past I've always wanted control to be returned to the dialplan as soon as possible. However, today I have a scenario where I want the script to remain running during the playback of a file so that I can read DTMF at the end of playback. However, doing this: GET DATA en_welcome 5000 6 Results (correctly) in the following in the asterisk console: -- SIP/a.b.c.d-dc027b50 Playing 'en_welcome' (language 'en') But the AGI continues to run on after this point, not waiting for either the sound file to be played, nor for the expected 6 DTMF digits. Adding a simple 10 second sleep/wait to the AGI allows the sound file to be successfully played back. I'm sure I must be missing something very obvious, buy my google-fu is failing me this afternoon. Suggestions gratefully received :-) Thanks in advance. Kind regards, Chris -- Have you tried increasing the timeout value in the command? To me, it appears to be too short. Try setting it to 5. -- Ron Bergin -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
I work with the 1.4 and 10.0 branches and do mainly PERL AGI's. In my testing the GET DATA hasn't worked very reliably. Just for grins, I copied test-agi.agi to get-dig.agi and made these changes on my 10.0.1 box 49,50c49,50 my $result = STDIN; checkresult($result); --- my $result2 = STDIN; checkresult($result2); 52,55c52,56 print STDERR 3. Testing 'sendimage'...; print SEND IMAGE asterisk-image\n; my $result = STDIN; checkresult($result); --- print STDERR 3. Testing 'get digit'...; print GET DATA vm-password 5000 6\n; my $result3 = STDIN; my $result3a=$result3; checkresult($result3); 58,60c59,61 print SAY NUMBER 192837465 \\\n; my $result = STDIN; checkresult($result); --- print SAY NUMBER $result3a \\\n; my $result4 = STDIN; checkresult($result4); 64,65c65,66 my $result = STDIN; checkresult($result); --- my $result5 = STDIN; checkresult($result5); 69,70c70,71 my $result = STDIN; checkresult($result); --- my $result6 = STDIN; checkresult($result6); 72c73 print STDERR 6a. Testing 'record' playback...; --- print STDERR 7. Testing 'record' playback...; 74,75c75,76 my $result = STDIN; checkresult($result); --- my $result7 = STDIN; checkresult($result7); And added this dialplan snippet exten = 1300,1,answer() exten = 1300,n,AGI(get-dig.agi) exten = 1300,n,playback(vm-goodbye,noanswer) exten = 1300,n,hangup() The result - vm-password is played and it waits 5 seconds as you might expect. BUT - whether or not I enter anything, the playback is always 200. So, in my opinion, you would be better off using the dialplan and two agi's if you need DTMF input between. -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Chris Bagnall Sent: Wednesday, February 22, 2012 9:14 AM To: asterisk-users@lists.digium.com Subject: Re: [asterisk-users] AGI: blocking script until playback complete On 22/2/12 2:55 pm, Danny Nicholas wrote: You don't state the Asterisk version you are running, but personal experience tells me you'd better invest in some Rogaine if you're depending on the built-in stuff from AGI for DTMF input. I have personally wasted weeks trying it. Sorry, should have said, latest 1.4 release. Care to elaborate a little on the issues you found when you tried it? Kind regards, Chris -- This email is made from 100% recycled electrons -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
I gave it from phpagi. It works for me using phpagi's function get_data http://phpagi.sourceforge.net/phpagi22/api-docs/phpAGI/AGI.html Regards, Zohair Raza On Wed, Feb 22, 2012 at 7:20 PM, Chris Bagnall aster...@lists.minotaur.ccwrote: The problem seems to be that GET DATA returns control to the script before the audio file has even played, let alone any DTMF tones have been entered. I would have expected script execution to be blocked until the result from GET DATA was available. -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
On 22/2/12 3:39 pm, Ron Bergin wrote: Have you tried increasing the timeout value in the command? To me, it appears to be too short. Try setting it to 5. Thanks for the suggestion - I tried 5, but no difference, it's not waiting at _all_ for the playback to complete. Just for giggles, I tried exactly the same test on a 1.8 box I have for testing, and the same problem occurs. I'm sure I must be doing something wrong here :-) Kind regards, Chris -- This email is made from 100% recycled electrons -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
On Wed, 22 Feb 2012, Chris Bagnall wrote: However, today I have a scenario where I want the script to remain running during the playback of a file so that I can read DTMF at the end of playback. If by 'remain running' you mean 'do other stuff while the file is playing' you can stream the file in a separate thread while continuing with the 'mainline' code. If you mean your script is returning to the dialplan before the file is finished playing, you're doing something wrong. However, doing this: GET DATA en_welcome 5000 6 Results (correctly) in the following in the asterisk console: -- SIP/a.b.c.d-dc027b50 Playing 'en_welcome' (language 'en') But the AGI continues to run on after this point, not waiting for either the sound file to be played, nor for the expected 6 DTMF digits. Adding a simple 10 second sleep/wait to the AGI allows the sound file to be successfully played back. Sure sounds like you are doing something wrong. Anytime a 'sleep' helps, something is definitely wrong. Most AGI 'weirdness' can be traced to violating the AGI protocol. These are the most common mistakes: 0) Not using an established library. Nobody gets it right the first time :) 1) Not reading the AGI environment from STDIN before issuing any AGI requests. 2) Forgetting that every request must be followed by reading the response. 3) Doing any I/O on STDIN or STDOUT. These channels are connected to Asterisk, not any console. Don't even think about popping in a quick 'debugging printf.' Looking over my own AGI code, I don't see any examples where I used GET DATA. I tend to use STREAM FILE and WAIT FOR DIGIT. I'm a 1.2 Luddite, so any bugs I've been exposed to may have been fixed by now. -- Thanks in advance, - Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
On Wed, 22 Feb 2012, Zohair Raza wrote: Try passing escape character GET DATA $filename $timeout $max_digits $escape_character Why? Is this 'extra' parameter documented in your version of Asterisk? -- Thanks in advance, - Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
On Wed, 22 Feb 2012, Danny Nicholas wrote: So, in my opinion, you would be better off using the dialplan and two agi's if you need DTMF input between. I've written complete 'applications*' as single AGIs so the combination of STREAM FILE and WAIT FOR DIGIT works reliably for me. *) voicemail, chat services, credit card processing, listen to stories, blah, blah, blah. -- Thanks in advance, - Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
Yes, but it doesn't seem to indicate if the timeout is in seconds of milliseconds. pbx*CLI agi show commands topic get data -= Info about agi 'get data' =- [Syntax] get data file [timeout] [maxdigits] [Description] Stream the given file, and receive DTMF data. Returns the digits received from the channel at the other end. [Synopsis] Prompts for DTMF on a channel [Runs Dead] No [See Also] Not available -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Steve Edwards Sent: Wednesday, February 22, 2012 4:25 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] AGI: blocking script until playback complete On Wed, 22 Feb 2012, Zohair Raza wrote: Try passing escape character GET DATA $filename $timeout $max_digits $escape_character Why? Is this 'extra' parameter documented in your version of Asterisk? -- Thanks in advance, - Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Re: [asterisk-users] AGI: blocking script until playback complete
While it is never actually safe to assume anything about Asterisk, the general setting for seconds is milliseconds. -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Eric Wieling Sent: Wednesday, February 22, 2012 4:02 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] AGI: blocking script until playback complete Yes, but it doesn't seem to indicate if the timeout is in seconds of milliseconds. pbx*CLI agi show commands topic get data -= Info about agi 'get data' =- [Syntax] get data file [timeout] [maxdigits] [Description] Stream the given file, and receive DTMF data. Returns the digits received from the channel at the other end. [Synopsis] Prompts for DTMF on a channel [Runs Dead] No [See Also] Not available -Original Message- From: asterisk-users-boun...@lists.digium.com [mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Steve Edwards Sent: Wednesday, February 22, 2012 4:25 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] AGI: blocking script until playback complete On Wed, 22 Feb 2012, Zohair Raza wrote: Try passing escape character GET DATA $filename $timeout $max_digits $escape_character Why? Is this 'extra' parameter documented in your version of Asterisk? -- Thanks in advance, - Steve Edwards sedwa...@sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000 -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users -- _ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users