Calling PHP and Drupal functions from inside a script
Last updated on
30 April 2025
When handling VoipScript parameters, VoIP Drupal processes strings that start with the ^ symbol as expressions to be evaluated. For instance, in the following example,
// get the report
$script->addSet('forecast_result', '^_get_forecast(%zip_code)');
// say the weather report
$script->addSay('%forecast_result');
The variable forecast_result is set with the result of the function _get_forecast().
The same mechanism can be used to call specialized callback functions to process data collected during call execution:
$prompt = t("Please record your message after the beep. When done, press the pound key.");
$timeout = 5;
$end_key = '#';
$script->addRecord($prompt, $timeout, $end_key);
$script->addSay(t('About to start processing the recorded file.'));
$script->addSet('callback_result',
'^_record_callback(%call_id, %recording_url, %recording_duration)');
$args = array('@result' => '%callback_result');
$script->addSay(t('The callback returned: @result', $args));
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion