Data recording in IVR


I use FreePBX 13.

I was wondering whether it is possible to record/save the responses a caller inters in an IVR. For example, if there is an option to choose 1 or 2, and he chooses 1, then is it possible to somehow save this information in an excel sheet or CSV or another form of database? Also, is it possible to ask for numerical inputs and save them, for example, ask for age and save the response?

I would much appreciate your help.


Yep. Are you comfortable manually editing your dialplan a little bit?

Yes totally!

I am a relative noob though, and I have seen the option for the dialplan at several places in the softwere, so please do give me detailed instructions if possible.

Thanks :slight_smile:

Test in FreePBX Distro 10.13.66-64bit

This code will let you record what the callers pressed in your ivr.

You can either modify existing IVRs, or create some net new ones.

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 copying small portions of the IVR code that FreePBX generates every time you press SUBMIT into an override file which allows us to modify without GUI changes in future of other parts of the PBX automatically overwriting our custom updates.

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

Example output: (DATE, CallerID, UniqueID, FreepbxIVRid,Selection)
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. This is if you have multiple IVRs that you want to do this mod to.

Selection= This is the DTMF value they pick for their answer.


1> open up the file: /etc/asterisk/extensions_additional.conf

2> Find the IVR in question that you want to record the prompts to. They are relatively easy to find, the start with a heading [ivr-X]

3> Copy the IVR’s entire sub-section into /etc/asterisk/extensions_override_freepbx.conf

EXAMPLE: Below is a snippet of an IVR that I tested with called IVR-7 in the FreePBX dialplan

[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] ==–;

4> Now that you have it pasted in the overrides section, you want to modify it.

You’ll see the following entries in your IVR. My IVR had 2 entries, you will just repeat the process for the number of choices you have.

EXAMPLE: Your IVR will have something very similar to below.

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

The modification is easy. For each selection your particular IVR would have, you add the “system” command and alter the exten numeric order.

Make the entire in you ivr that looks like this:
exten => 1,1(ivrsel-1),Goto(ivr-8,s,1)
exten => 2,1(ivrsel-2),Goto(ivr-8,s,1)

turn into this:

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

exten => 2,1,system(echo “${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)},${CALLERID(all)},${UNIQUEID},${IVR_CONTEXT},${EXTEN}” >> /tmp/ivrlog.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.

5> Save your changes

6> in the CLI type
core reload

This will load these entries into your PBX.

7> Make a call to the IVR and test the functionality.

8> Look in /tmp/ivrlog.txt, there should be entries like:

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

The system will keep appending to this file.

Thank you so much. Will give this a try and revert ASAP.


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