This is pretty easy. We can do it all through the GUI.
1> Select "DIALPLAN INJECTION"
in "DESCRIPTION" give it a name.
Then press SUBMIT
2> You will see that name appear on the right side.
Click on that name.
Now you will see a "COMMAND BOX"
put this in the command box:
set(CDR(accountcode)=${IVR_DIGIT_PRESSED})
In "DESTINATION" select "terminate call" then select "HANGUP"
Submit the changes.
4> Now create your IVR with the 5 options.
EACH extension, set the destination to this "dialplan inejction". Each IVR entry will goto the same one.
Save and submit your changes.
5> Test it out
Call the IVR, press a digit. The call should hang up.
Now go to your CDR table. You'll see the number that they pressed show up under "ACCOUNT/CODE" for that call.
The CDR table should also give you the duration of the call as you would expect as well.
The variable "IVR_DIGIT_PRESSED" contains the digit they pressed in the IVR. We're just storing that digit into the CDR table for easy retrieval.