This past weekend I built a simple Audio RPG using Twilio. You call a number and get injected into a storyline where you have to make decisions on how to procede. For example you might happen upon a NPC and get prompted to try and be friends, run away, or attack. This blog post will outline two methods for creating the prompt and directing the caller as needed.
At the basic level a Twilio phone menu for is TwiML (aka TwiML) that specifies how many digits to gather and where to send those digits for further instructions.
This will gather digits until the caller hits the # key at which point Twilio will make a GET request to process.php including a GET variable of Digits with the value entered by the caller.
One aspect of the Audio RPG that was important to me was that it not require a server and that it should be easy to add story arcs. Originally I started with static TwiML on Gist but quickly ran into issues with Gist delivering the raw TwiML as Content-Type: text/plain. Twilio (correctly) reads that as text instead of parsing it as TwiML and interpreting it as a menu. I ended up getting it to work by using @GitHub Pages which is not quite as easy to use as Gist but provides more power for contributors.
Since the TwiML is going to be static and hosted on GitHub something needs to be done for the logic of the phone menu. Handily Twilio has a labs feature that provides just such functionality.
Simply by building a URL you can have the Twimlet generate the phone menu TwiML automatically. For example the following URL will prompt the caller to make a selection the redirect based on the digit gathered.
Give Audio RPG a try by calling (415) 689-9751
At the basic level a Twilio phone menu for is TwiML (aka TwiML) that specifies how many digits to gather and where to send those digits for further instructions.
This will gather digits until the caller hits the # key at which point Twilio will make a GET request to process.php including a GET variable of Digits with the value entered by the caller.
One aspect of the Audio RPG that was important to me was that it not require a server and that it should be easy to add story arcs. Originally I started with static TwiML on Gist but quickly ran into issues with Gist delivering the raw TwiML as Content-Type: text/plain. Twilio (correctly) reads that as text instead of parsing it as TwiML and interpreting it as a menu. I ended up getting it to work by using @GitHub Pages which is not quite as easy to use as Gist but provides more power for contributors.
Since the TwiML is going to be static and hosted on GitHub something needs to be done for the logic of the phone menu. Handily Twilio has a labs feature that provides just such functionality.
Simply by building a URL you can have the Twimlet generate the phone menu TwiML automatically. For example the following URL will prompt the caller to make a selection the redirect based on the digit gathered.
Give Audio RPG a try by calling (415) 689-9751
Comments
Post a Comment