I want to be able to use multiple Kynetx apps (rulesets) in a single phone call. Say the first app is a phone menu, and the second app provides the functionality for the menu option. How do I redirect from one to the other?
When you use a twilio:redirect() or twill:gather_start() action, the url you provide is a relative URL.
All twilio webhooks provided by Kynetx have the full URL of http://webhooks.kynetxapps.net/t/appid/eventname
If you pass in a URL relative to this, it will resolve relative to this. Example:
With a base URL of http://webhooks.kynetxapps.net/t/myappid/callstart
the action twilio:redirect("sayhello")
will resolve to http://webhooks.kynetxapps.net/t/myappid/sayhello
This will send in a new event to the same application.
If you want to switch apps, you can either provide the full URL, including the new appid, or use a relative URL like the following:
With a base URL: http://webhooks.kynetxapps.net/t/myappid/callstart
the action twilio:redirect("../newappid/sayhello")
resolves to: http://webhooks.kynetxapps.net/t/newappid/sayhello
Here is an example app which uses a different app for a menu choice.
ruleset firstappid {
meta {
name "Phone Menu App"
description <<
Provides the Phone Menu
>>
author "Sam Curren"
logging off
}
dispatch {}
global {}
rule menu {
select when twilio givemenu
{
twill:gather_start("../secondappid/menuchoice") with numDigits = 1;
twilio:say("Press 1 to speak do whatever.");
twilio:gather_stop();
}
}
}
And the app which receives the menu choice.
ruleset secondappid {
meta {
name "Phone Menu Option"
description <<
Provides the menu functionality
>>
author "Sam Curren"
logging off
}
dispatch {}
global {}
rule speak {
select when twilio menuchoice Digits "1"
{
twilio:say("This is what you get when you press 1.");
twilio:hangup();
}
}
}
By using the action twilio:redirect('../firstappid/givemenu')
instead of twilio:hangup()
, this rule could redirect back to the first app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With