[Freeswitch-users] Lua playAndGetDigits

Michael De Lorenzo delorenzodesign at gmail.com
Tue Mar 16 18:16:10 PDT 2010


What do you mean about the provider?  I'm not sure I understand that part.
I'm trying to call a number and have the call's recipient type the digits
in.

On Tue, Mar 16, 2010 at 9:07 PM, Aloysius Lloyd <lloyd.aloysius at gmail.com>wrote:

> here is the test script I used
>
> session:answer();
> digits = session:playAndGetDigits(1, 4, 1, 5000, "#", "enter-digits.wav",
> "", "\\d+");
>
> Here is the console log
>
> 2010-03-17 01:04:50.374761 [DEBUG] switch_ivr_play_say.c:1444 done playing
> file
> *2010-03-17 01:04:50.874736 [DEBUG] switch_rtp.c:2417 RTP RECV DTMF 1:800*
> *2010-03-17 01:04:51.104725 [DEBUG] switch_rtp.c:2417 RTP RECV DTMF 2:640*
> *2010-03-17 01:04:51.414710 [DEBUG] switch_rtp.c:2417 RTP RECV DTMF 3:800*
> *2010-03-17 01:04:51.774692 [DEBUG] switch_rtp.c:2417 RTP RECV DTMF 4:640*
> 2010-03-17 01:04:51.774692 [DEBUG] switch_ivr_play_say.c:1737 Test Regex
> [1234][\d+]
>
> You may have some issue with the provider. Check using a local extension.
>
>
> On Tue, Mar 16, 2010 at 8:51 PM, Michael De Lorenzo <
> delorenzodesign at gmail.com> wrote:
>
>> Ok, I updated the console log level, and there are no DTMF values being
>> detected:
>>
>> 4268 -> 74.51.38.156 port 15150 codec: 0 ms: 20
>> 2010-03-16 20:49:06.534030 [DEBUG] switch_rtp.c:1181 Starting timer [soft]
>> 160 bytes per 20ms
>> 2010-03-16 20:49:06.535030 [NOTICE] sofia_glue.c:3128 Pre-Answer
>> sofia/external/19736327407!
>> 2010-03-16 20:49:13.762610 [DEBUG] sofia.c:4139 Channel
>> sofia/external/19736327407 entering state [completing][200]
>> 2010-03-16 20:49:13.762610 [DEBUG] sofia.c:4150 Remote SDP:
>> v=0
>> o=root 21648 21649 IN IP4 74.51.38.156
>> s=session
>> c=IN IP4 74.51.38.156
>> t=0 0
>> m=audio 15150 RTP/AVP 0 101
>> a=rtpmap:0 PCMU/8000
>> a=rtpmap:101 telephone-event/8000
>> a=fmtp:101 0-16
>> a=silenceSupp:off - - - -
>> a=ptime:20
>>
>> 2010-03-16 20:49:13.762610 [DEBUG] sofia.c:4139 Channel
>> sofia/external/19736327407 entering state [ready][200]
>> 2010-03-16 20:49:13.763613 [NOTICE] sofia.c:4663 Channel
>> [sofia/external/19736327407] has been answered
>> 2010-03-16 20:49:13.763613 [DEBUG] switch_ivr_originate.c:3107 Originate
>> Resulted in Success: [sofia/external/19736327407]
>> 2010-03-16 20:49:13.763613 [DEBUG] switch_cpp.cpp:497
>> (sofia/external/19736327407) State Change CS_CONSUME_MEDIA ->
>> CS_SOFT_EXECUTE
>> 2010-03-16 20:49:13.763613 [DEBUG] switch_core_session.c:1018 Send signal
>> sofia/external/19736327407 [BREAK]
>> 2010-03-16 20:49:13.764618 [DEBUG] switch_ivr_play_say.c:1178 Codec
>> Activated L16 at 8000hz 1 channels 20ms
>> 2010-03-16 20:49:13.764618 [DEBUG] switch_core_state_machine.c:314
>> (sofia/external/19736327407) Running State Change CS_SOFT_EXECUTE
>> 2010-03-16 20:49:13.764618 [DEBUG] switch_core_state_machine.c:354
>> (sofia/external/19736327407) State SOFT_EXECUTE
>> 2010-03-16 20:49:13.764618 [DEBUG] mod_sofia.c:510 SOFIA SOFT_EXECUTE
>> 2010-03-16 20:49:13.764618 [DEBUG] switch_core_state_machine.c:200
>> sofia/external/19736327407 Standard SOFT_EXECUTE
>> 2010-03-16 20:49:13.764618 [DEBUG] switch_core_state_machine.c:354
>> (sofia/external/19736327407) State SOFT_EXECUTE going to sleep
>> 2010-03-16 20:49:13.794735 [DEBUG] switch_rtp.c:2055 Correct ip/port
>> confirmed.
>> 2010-03-16 20:49:25.055402 [DEBUG] switch_ivr_play_say.c:1470 done playing
>> file
>> 2010-03-16 20:49:30.074803 [INFO] switch_cpp.cpp:1142 Digits received
>> during call from playAndGetDigits:
>> 2010-03-16 20:49:30.074803 [INFO] switch_cpp.cpp:1142 Did this check out?
>> no
>>
>>
>> On Tue, Mar 16, 2010 at 8:37 PM, Aloysius Lloyd <lloyd.aloysius at gmail.com
>> > wrote:
>>
>>> set the console log level to 7. Then you can see the DTMF values in
>>> console log , while you are pressing the keys.
>>>
>>> Lloyd
>>>
>>>
>>> On Tue, Mar 16, 2010 at 8:23 PM, Michael De Lorenzo <
>>> delorenzodesign at gmail.com> wrote:
>>>
>>>> So I tried Michael's suggestion of:
>>>>
>>>> digits = session:playAndGetDigits(1, 4, 1, 5000, "#",
>>>> get_digits_message, "", "\\d+");
>>>>
>>>> but it still didn't detect that I had pressed any keys.  What would
>>>> cause this?  Is there someplace I can check to see if anything at all is
>>>> being detected?
>>>>
>>>>
>>>> On Tue, Mar 16, 2010 at 5:00 PM, Michael Collins <msc at freeswitch.org>wrote:
>>>>
>>>>>
>>>>>
>>>>> On Tue, Mar 16, 2010 at 1:21 PM, Michael De Lorenzo <
>>>>> delorenzodesign at gmail.com> wrote:
>>>>>
>>>>>> I'm having some trouble getting consistent results with
>>>>>> playAndGetDigits, sometimes the digits are record and other times they're
>>>>>> not.  It seemed to have something to do with how quickly the digits were
>>>>>> pressed, but now that no longer seems to be the case.
>>>>>>
>>>>>> I'm trying to have users press a confirmation code, in this case
>>>>>> "1111" although I'd like to make it accept "1" or "11" or "111" or "1111" if
>>>>>> possible.
>>>>>>
>>>>>> Can anyone point me in the right direction?
>>>>>>
>>>>>>
>>>>>>     session =
>>>>>> freeswitch.Session("{ignore_early_media=true}sofia/gateway/" .. provider ..
>>>>>> "/1" .. number_to_call);
>>>>>>
>>>>>>     while(session:ready()) do
>>>>>>        session:answer();
>>>>>>        session:setInputCallback("onInput","true");
>>>>>>
>>>>>>        --playbackMessage(check_message);
>>>>>>        digits = session:playAndGetDigits(4, 4, 1, 5000, "",
>>>>>> get_digits_message, "", "[1]");
>>>>>>
>>>>>
>>>>> You are specifying a minimum of four and a maximum of four digits.
>>>>> Also, your regex will match any string that has a digit 1 in it, which may
>>>>> or may not be what you are looking for. Lastly, you haven't specified a
>>>>> terminator key (like "#") but you are giving the user only one try and
>>>>> waiting 5000ms for the entry. Try something like this:
>>>>>
>>>>> digits = session:playAndGetDigits(1, 4, 1, 5000, "#",
>>>>> get_digits_message, "", "\\d+");
>>>>>
>>>>> Let us know if that works. Oh, one other thing: you might want to add
>>>>> an invalid message because playAndGetDigits will handle invalid input for
>>>>> you.
>>>>> -MC
>>>>>
>>>>> P.S. - This topic is covered in greater detail in Chapter 7 of the
>>>>> upcoming FreeSWITCH book. ;)
>>>>>
>>>>>
>>>>>
>>>>>>        freeswitch.consoleLog("info", digits .. "\n");
>>>>>>        freeswitch.consoleLog("info", "Did this check out? " ..
>>>>>> (check_message == true and "yes" or "no" .. "\n"));
>>>>>>
>>>>>>        -- we got what we're looking for, so we can end this
>>>>>>        if(check_success) then
>>>>>>           freeswitch.consoleLog("info", "A positive response was
>>>>>> received from this check.\n");
>>>>>>           break;
>>>>>>        else
>>>>>>           -- not a positive response
>>>>>>           -- if we reached our max attempts, we're finished move on
>>>>>>           if(attempts == max_attempts) then
>>>>>>             freeswitch.consoleLog("info", "We've reached our maximum
>>>>>> attempts for this number.\n");
>>>>>>             break;
>>>>>>           end
>>>>>>        end
>>>>>>     end
>>>>>>
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> FreeSWITCH-users mailing list
>>>>> FreeSWITCH-users at lists.freeswitch.org
>>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>>> UNSUBSCRIBE:
>>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>>> http://www.freeswitch.org
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org
>>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>>> UNSUBSCRIBE:
>>>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>>>> http://www.freeswitch.org
>>>>
>>>>
>>>
>>> _______________________________________________
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>>> http://www.freeswitch.org
>>>
>>>
>>
>> _______________________________________________
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
> _______________________________________________
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20100316/c30d8388/attachment-0002.html 


More information about the FreeSWITCH-users mailing list