This step-by-step recipe will allow us to create an IVR that will store the
digits or user’s input in a log file after playing a welcome prompt. It will
then return an exit code to the IVR to signal the next action to take, e.g.
play another prompt, end the call or play another script-based IVR.
The “Launch Script” IVR type can be used in both Linux or Windows. On Linux,
you can use scripts written in bash or even use more advanced and complex
languages like Python or Perl. The only limit is your imagination. First,
let’s create the script following these steps:

**vim /home/pi/script/test_ivr_script_0.sh**
`**#!/bin/bash
logFile="/var/log/3cx_automation.log"
echo Ran script $0 with parameters: >> "${logFile}"
echo CallerID: $1, DIDNumber: $2, CallerInput: $3 >> "${logFile}"
echo _________ >> "${logFile}"
exit 3**`
**chown phonesystem:phonesystem /home/pi/script/test_ivr_script_0.sh**
**touch /var/log/3cx_automation.log
chown phonesystem:phonesystem /var/log/3cx_automation.log**
Now to create a new script-based IVR, go to “Digital Receptionist” in the PBX Management
Console and follow these steps to add a New Digital Receptionist:

**tail -f /var/log/3cx_automation.log**
Though this is a straightforward and easy recipe, script-based IVRs have a
limit of up to 101 exit codes and can call another IVR menu, script-based or
not. As you can see, possibilities are endless, as you can include in your
script database access, employ third-party APIs, etc. For example, the code we
used for this example can execute another script, with the user’s input as a
parameter for storing in a database.
Read our guide on Creating Script-based IVRs for more info.
The post How to Execute a Custom Script from Your
IVR appeared
first on Elastix.