How to get Inputs from IVR freepbx?

Hello,

Sometimes in IVRs we are asked to enter our phone number or card number.
How to retrieve the keys entered by the user without being pre-registered?

Thank you!

IVR usually uses to let people from outside to call in. so, the customer has not need to register. you have to set the IVR and destination first. the system will collect the dtmf the customer pressed.

1 Like

Do you want a prompt that will ask a user for a PIN number? If so, what do you want to do with this pin number

https://www.voip-info.org/wiki/view/Asterisk+cmd+Set
https://www.voip-info.org/wiki/view/Asterisk+cmd+Read
http://asterisk-service.com/downloads/Asterisk-%20The%20Definitive%20Guide,%204th%20Edition.pdf (page 138)

1 Like

@dickson Yes and i can do that with Annoncement or something like that.I just want to get that pin in a text file.
@comtech intesresting links I’m gonna take my time to study all this. In your second link i see Asterisk 1.0, 1.2 and 1.4, what about the newer version like mine 13.19.1?

Thanks to all.

Look at my “TimeTrex Integration” post

For other ways to interact with the system.

1 Like

Humm Interesting!
Thanks.

Do you want the values collected put into a text file that you can access? Do you want a separate file for each call? Or append the entries to a single file

Yes and yes separate or append does matter.

I’ll write up a procedure how to do this for you and post early next week

1 Like

Thank you :hugs:, I’m gonna look forward to you.

The third party module dynroutes can do this.

I’d love to see this too.

Thanks, that sounds interesting. I just installed it (my first module installation) but I have no idea how to use it. And this doc doesn’t help too much. I think I’ll wait for dickson.

As promised and requested

WHAT IT DOES
This dialplan will ask the user to enter in a pin number, and then it will save it to a file.
Tons more you can do with this and tweaks of course, but this is an example of what you can do.

I’m using all the default recordings in asterisk, so they aren’t perfect prompts, but good enough for you to test with. Happy to try and help with any tweaks or modifications you might have.

Installation
1> Open up /etc/asterisk/extensions_custom.conf

2> Paste the code between the snips into this file.
===== snip ======

[macro-pincollection]
exten => s,1,Answer()
;we set a variable to prevent looping over and over in IVR, either by accident or malicious
exten => s,n,Set(Attempts=1)

;throw a entry in the asterisk log that system is requesting a PIN entry
exten => s,n(begin),NooP(&&&&&&& Collecting PIN info for ${CALLERID(all)} attempt ${Attempts} &&&&&)

exten => s,n,Playback(please-enter-your&pin_number)

;system listens for DTMF and records it in variable "pinnumber"
;the syntax at the end= 7=MAX DIGITS, 1=attempts if no data, 10=timeout.   The ",," value i'm not using in this code example)
exten => s,n,Read(pinnumber,then-press-pound,7,,1,10)

;system checks for blank value and asks again
exten => s,n,ExecIf($["${pinnumber}"=""]?goto(macro-pincollection,s,1))

;systems plays back the number they entered in to caller
exten => s,n,Playback(you-entered)
exten => s,n,SayDigits(${pinnumber})

;system asks them to press 1 to accept or 2 to retry
exten => s,n,Playback(if-this-is-correct-press)
exten => s,n,SayDigits(1)
exten => s,n,Playback(otherwise-press)
exten => s,n,SayDigits(2)

;system listens for the value entered
exten => s,n,Read(digi,,1)

;this section we test for invalid entries.  On their 4 try we hangup.  We dont want someone looping over and over again. 
exten => s,n,Set(Attempts=${MATH(${Attempts}+1,i)})

;if they reach their 4th attempt, system plays some messages and hangsup.  
;Change the "4" to a different value if you want to increase/decrease chances
;Change the "HANGUP to RETURN" if you want the system to go back to a different location as set in the CUSTOM DESTINATIONS section

exten => s,n,ExecIf($["${Attempts}"="4"]?playback(sorry-youre-having-problems))
exten => s,n,ExecIf($["${Attempts}"="4"]?playback(hangup-try-again))
exten => s,n,ExecIf($["${Attempts}"="4"]?HANGUP())

;if user presses 1 to confirm, system sends the clal on
exten => s,n,ExecIf($["${digi}"="1"]?goto(writevalue))

;if callers presses any other digit, system will re-ask them to enter in their number
exten => s,n,goto(macro-pincollection,s,begin)

;If they press "1" as being a valid entry, the entry is written into the file.
;system writes the pin collected to the file 'pincollected.txt'
;saved as "DDMMYYY-HH:MM:SS, CALLERid, UNIQUE NUMBER (to trace call in logs easier if needed), PINNUMBER
exten => s,n(writevalue),system(echo "${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${pinnumber}" >> /tmp/pincollected.txt)
exten => s,n,Return

===== snip ======

3> Save these changes

4> Open up FreePBX

5> Go to ADMIN-CUSTOM DESTINATIONS

6> Create a new destination
TARGET = macro-pincollection,s,1
Description= Collect Pin and save
Notes= blank (you can put something in if you want)
Return = YES
DESTINATION= IVR – ivrtype
(the destination in this case is what you want to have happen when they enter their pin number. In my example I wanted the code to continue on, but if you say “no” for RETURN then the system will hangup after the call.

7> Save changes

8> Open up your IVR and put in an entry in it to go to this custom destination
example:
If they press “2” in your ivr, select “CUSTOM DESTINATION” then select “Collect Pin and save”

9> Save your changes, then submit.

10> TEST!

Dial the number that will trigger this. In my example I all the IVR then pressed “2”
System will ask you to enter your pin, then will play it back to confirm and then if “YES” is selected, it will save it to /tmp/pincollected.txt DDMMYY-HHMMSS, CLID info, unique ID, pin#entered

02042018-11:51:38,John Smith <123-555-1165>,1522680683.98551,123
02042018-11:54:49,Jane Doe <123-555-4455>,1522680864.98560,1234

7 Likes

Thanks for taking the time. I can’t wait to test it.
Right now I’m trying to set up my freepbx because I no longer have access to it, I think it’s probably due to the fact that I moved and so I have a new ip address.
As soon as I finish testing your code (configuration) I’ll come back to you.

Ok, i settup inbound route to go to my IVR and I do have the message that asks me to enter the pin code.
But after entering it it does not give me time to confirm with the 1 key, it continues to request the pin code again.
I think the loop came too soon.
Maybe I have to close the parenthesis here? :

;system listens for the value entered
exten => s,n,Read(digi,1

I’m not near a machine to test but I see the problem. i didn’t copy/paste properly. Sometimes this forum system interprets characters improperly.

In this line it’s missing an extra comma after 7. It should be like this
exten => s,n,Read(pinnumber,then-press-pound,7, ,1,10)
Just no space between comma.
Yes there should be close bracket on the read digi line

Try making those changes. In cli type “core reload” to get changes

When I’m in front of a computer in a couple of hours I’ll repost the code in proper style for forum

I’ve edited my original post. Replace your code with what I’ve reposted. It should work. :slight_smile: let me know.

This is a wonderful world! It’s working! :grinning:
Dickson you have my eternal gratitude.:hugs::heart_eyes:
And to have more fun with custom_extensions.conf where in the documentation should I look for the syntax?