Cloud Workflow

Call Center with Twilio, without Telephone Machine (Touch-tone Entry to Trigger the Order Process)

An Automatic Order Receiving system built with Twilio and Questetra!

I am going to work on Twilio to celebrate their official service launch in Japan.

This time, I would like to change the flavor, thinking over that a company has a dedicated telephone number for receiving goods orders, a user makes a phone call to order goods by touch tone data entry. The following is a scenario to make it simple.

  • When a user places a phone call to order Call Center, Twilio prompts the user to enter the number of the ordering in its automatic response.
  • The user enters the number of orders with the touch tone keys, then enters ‘*’ at the end.
  • Twilio automatically repeats the number of orders that have been entered, then hang up the call.
  • Twilio passes the number of orders to Questetra BPM Suite, so an Ordering Process to be started.


== 1. A User Places a Phone Call to the Order Call Center ==

Getting one phone number from Twilio in advance, and use it as an Order Call Center. This scenario starts with a user placing a phone call to the number.

== 2. HTTP Request from Twilio to Google Apps Engine ==

Twilio will transmit an HTTP request to the URL of Google Apps Engine which registered in advance, on receiving a phone call.

== 3. Google Apps Engine Responses TwiML ==

Configure in the Google Apps Engine to let it respond an XML (TwiML) as follows at receiving an HTTP Request from Twilio.

  <Gather finishOnKey="*" action="" method="post" timeout="30">
    <Say voice="woman" language="en">Please push the number you want to order, then push * at the end.</Say>

<Gather> is a tag to instruct acquisition of the value of Touch tone entry. The attribute of ‘finishOnKey’ is to specify the key to finish the inputting, the attribute of ‘action’ is to specify the destination URL of HTTP Request that is conducted at the end, and the attribute of ‘method’ is to specify the type of the HTTP Request. The attribute of ‘timeout’ is the maximum time to wait for the user to input.

== 4. Twilio Tells, the User Inputs ==

Twilio processes according to the TwiML which received from the Google Apps Engine. First, Twilio automatically tells the user that ‘Please push the number…’ Then the user input the number of the orders in Touch Tone entry, and pushes ‘*’ at the end.

== 5. HTTP Request from Twilio to Google Apps Engine ==

On receiving ‘*’ input by the user, Twilio transmits an HTTP Request to Google Apps Engine. The destination URL is the one that has been specified by the ‘action’ attribute in the <Gather> tag in the above.

== 6. HTTP Request from the Google Apps Engine to Questetra BPM Suite ==

Receiving the HTTP request from Twilio, the Google Apps Engine will parse its contents. I have written a program for it, and here is the link to my program. CallEndServlet (This is a Java program even though the extension is ‘txt’. It is because of this web site.) The followings are the main points.

String from = request.getParameter("From");
String digits = request.getParameter("Digits");
int order = 0;
try {
  order = Integer.parseInt(digits);
} catch (NumberFormatException e) {}

TwiMLResponse twiml = new TwiMLResponse();
  Say say = new Say("Confirming the number of your orders is" + order + "Thank you for your ordering.");
} catch (TwiMLException e) {
  throw new IOException(e);

response.setContentType("application/xml; charset=UTF-8");

if (from != null && digits != null) {
  sendToQbpms(from, order);

The ‘from’ is a Request parameter that contains the originating phone number, and the ‘Digits’ is a Request parameter that contains the value of Touch Tone Entry. The Google Apps Engine retrieves these values and transmits an HTTP Request to the Message Start Event of Questetra BPM Suite.

Here, it responds TwiML as well, but this time it generates TwiML dynamically using Twilio’s library. The responding TwiML contents are like below. The part of the ordering number “2” varies dynamically depending on the value of Touch Tone Entry of the user.

    <Say voice="woman" language="en">Confirming the number of your orders is 2. Thank you for your ordering.</Say>


How was this article? I have one complaint related to this article for Twilio. That is in Japanese language, the Text-to-speech synthesis of the Twilio misreads the word of ‘number’. I expect Twilio will brush up their Text-to-speech synthesis in Japanese language.


== Related Blog post ==

Prev article - 15. Ambitions What is This Thing Called 'Business Process'?
Next article - 15. Ambitions Call Center with Twilio, without Telephone Machine (Message Recording)
Another article - Hatanaka Akihiro Application via Enterprise Portal