How to store ivr's DTMF choices as text document

Hi, i’m a proud freepbx noob, first time i write in this forum but you guys have helped me really well in the last couple months.
I have my freepbx 13 pretty much setup. It can call, receive calls, use ivr’s, broadcast campaigns, ucp and zulu, start conferences and so on. Now i need to know where it stores DTMF choices, so when i broadcast a campaign and calls are routed to my ivr it could ask a survey and make a report.

Thanks for your time, your doing a terrific job.

You can’t use an IVR for surveying because the input is not saved anywhere. There is no way to do a survey out of the box, you will need a mix of custom dialplan and possibly use the 3rd party module, dynamic routes.

Thanks for your quick answer, i’m studying dynroutes, but i’m not familiar with dialplan creation; can you link me a good place to start? The only related post i found was 10 years old.

Thanks again.

Here’s a quick hack that would give you want you want I think (or at least a start)

There’s some manual editing of the dialplan, but this might not be a problem if you dont change your survey’s very often?
Anyway, its free…easy to test, and very easy to backout of if you have a problem.
I suggest just test with 1 IVR to get an idea of how it would work, and see if it works for you.

Were basically copy small portions of the IVR code into an override which allows us to modify without GUI changes in other parts of the PBX automatically overwriting our custom updates.

This records the IVR selections and save them into a file called survey.txt
The comma delimited file contain each IVR selection broken up in this manner:


07092017-22:35:03,Jane Doe <5551238811>,1504834501.1207,ivr-7,custom/question1,1

CallerID=The callers CLID if available "Jane Doe <5551238811>"
UniqueID=This is the unique value for each call. This will help you sort indvidual calls that are in this file.
FreepbxIVRid=Each IVR you create is assigned an IVR. FreePBX doesn’t store the descriptive name, this is here to help you know which one is which.
QuestionFilename=This is the sound file that you play for each IVR. This is to help you know what question was asked
Selection=This is the DTMF value they pick for their answer.

Dont throw this into production, put it in a test system, or just change 1 IVR.
Test in FreePBX Distro 10.13.66-64bit

You can either modify existing IVRs, or create some net new ones.
I suggest that your recorded questions file names allow you to reflect the question being asked because the way FreePBX builds the dialplans and references each IVR a unique ID number, the voicefile name is the only thing that easily lets you see which IVR is which.

open up /etc/asterisk/extensions_additional.conf

Copy all your IVR CONTEXT entries in this file that are relative to your IVR questions, and paste them into

If you have other production IVRs, I wouldn’t copy them into this file. They will still work, but any changes in the GUI will not reflect in your production sytem, as the override file will do just that, override changes made by the GUI.

So below is a ‘snipped’ version of the 30 or 40 lines of code you would see. If you had 5 Ivrs, you would have to copy them all.

[ivr-7] ; ivr1
include => ivr-7-custom
include => from-ivr-directory-Disabled
exten => s,1,Set(TIMEOUT_LOOPCOUNT=0)
exten => hang,1,Playback(vm-goodbye)
exten => hang,n,Hangup
;--== end of [ivr-7] ==--;

copy everything from
[ivr-X] through to ;-== end of [ivr-X] ==–;

Paste it into

Now that you have all the IVRs that belong to your survey, you can now edit them. We move them here because manual changes in their home file location would be over written by future changes in the GUI.

Now go to each IVR in the _override.conf file and look for the entries that look similar to this:


exten => 1,1(ivrsel-1),Goto(ivr-8,s,1)
exten => 2,1(ivrsel-2),Goto(ivr-8,s,1)

These are the valid selections in each IVR you’ve configured in FreePBX. So in the above example callers in IVRx can press 1 or 2, and will take them to the next ivr for further questions.
We are going to modify each one of these lines with the same piece of code:

system(echo “${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${IVR_CONTEXT},${IVR_MSG},${EXTEN}” >> /tmp/survey.txt)

We’ll insert this into the exsting code

exten => 1,1(ivrsel-1),Goto(ivr-8,s,1)
turns into this:

exten => 1,1,system(echo “${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${IVR_CONTEXT},${IVR_MSG},${EXTEN}” >> /tmp/survey.txt)
exten => 1,2(ivrsel-1),Goto(ivr-8,s,1)

exten => 2,1(ivrsel-2),Goto(ivr-8,s,1)

turns into this:

exten => 2,1,system(echo “${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${IVR_CONTEXT},${IVR_MSG},${EXTEN}” >> /tmp/survey.txt)
exten => 2,2(ivrsel-2),Goto(ivr-8,s,1)

You’ll need to repeat this entry for each entry you have in the IVRS.

Save your changes

in the CLI type
core reload

This will load these entries into your PBX.

Make a call to the IVR and test the functionality.

Look in /tmp/surevey.txt, there should be entries like:

07092017-22:35:03,Jane Doe <8862>,1504834501.4403,ivr-7,custom/question1,1
07092017-22:35:03,Jane Doe <8862>,1504834501.4403,ivr-5,custom/question2,2
07092017-22:35:03,Jane Doe <8862>,1504834501.1207,ivr-7,custom/question1,1
07092017-22:35:03,Jane Doe <8862>,1504834501.1207,ivr-5,custom/question2,2

Isn’t there a HowTo section on here? This would be a terrific thing to add to that! Good work.

Thank you very much dickson, i still haven’t test this since my client isn’t interested anymore in this feature and asked me 4 more systems… anyway you did a terrific job and i’m eager to test this once i have some spare time; i’ll upload and thanks again!

Thank you dikson,I applied the configuration,but there is no data write on /tmp/survey.txt.
-rwxrwxrwx 1 asterisk asterisk 0 Sep 22 09:16 survey.txt
can you help me?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.