Dovetail Software Makes Phone Calls From Their CRM with Twilio

April 15, 2009
Written by
Danielle Morrill
Contributor
Opinions expressed by Twilio contributors are their own

Twilio Bug Logo

Dovetail-software
Guest post by Kevin Miller

Dovetail Software

Can your CRM place a phone call?

When
new cases come in we have many ways of having our support team notified
so we can provide speedy assistance to our customers.

Recently
we needed a better way to notify on-call support agents of new cases.
Our existing notification mechanisms work great during office hours but
at night a spam email getting past my filters better not wake me up at
2am just because it might be a new support case. We needed something
better. The simplest thing we could think of was to have our CRM make a phone call.

Phone
calls are cross platform. No special smart phone client application
beats a phone call. Better yet spammers don’t place calls  at 2am
pitching “Enlargement”. At night I can confidently leave my phone
volume set to 11 with a screeching Ride of the Valkyries ring tone and I sleep in peace knowing that if my phone rings at 2am it is truly important. Or else I should get friends that don’t drunk dial me. Stop it guys. You know who you are.

What I Want To Happen

We
need a rule in our CRM system that places a phone call to the current
on-call support agent when an Urgent or High priority case comes in.

We already have Rulemanager which we have talked about many times before.
The new thing here is having a rule action that places the phone call.
Kudos and bonus points if it could say something catchy like “There is
a new Urgent or High priority support case.” The Agent receiving the
call at this point can use our Dovetail Mobile web application to work the case.

What Didn’t Work

We don’t have a fancy PBX or the Telephony skills and hardware to setup our own Asterisk server.

Skype seemed like a good inexpensive solution as they have Skype Out and a Skype4Com API
that seems pretty nice. Sadly my attempts to get the Skype API working
were only intermittently successful and I have learned to avoid COM
whenever possible so I moved on.

Jajah looked interesting. Ribbit I just don’t understand. PhoneNotify seemed perfect but expensive and the API looks a little klunky.

Then I Found Web + Telephony Simplicity

Twilio is a telephony web service that is simple to use, quite powerful, and priced very reasonably.

Twilio Homepage

Our make a phone call requirement appears to be Twilio’s most basic capability. To do this essentially all you need to do is call the Calls Rest API giving it a number to call and the public URL of a script which will control the conversation.

Start A Call

To
have our CRM place a call we need to have Rulemanager run a console
application giving it a number of the current on-call agent. To do this
we created a rule whose action calls a console application passing it a
phone number as the first argument.

This Support-Dialer console application will invoke the Twilio Calls Rest API. Twilio makes it easy for .Net developers by having a thin C# helper library with good examples. Here are the important bits of the Support-Dialer console application.

<span class="kwrd">private</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
{
 var logger = GetLogger();

 <span class="kwrd">if</span>(args.Length < 1 )
 {
 <span class="kwrd">const</span> <span class="kwrd">string</span> message = <span class="str">"Could not dial number as no arguments were supplied"</span>;
 logger.ErrorFormat(message);
 <span class="kwrd">return</span>;
 }

 var phoneNumberToCall = args[0];
 logger.InfoFormat(<span class="str">"Calling {0}."</span>, phoneNumberToCall);

 <span class="rem">// Create Twilio REST account object using Twilio account ID and token</span>
 var account = <span class="kwrd">new</span> Account(AccountSid, AccountToken);

 <span class="rem">// Initiate a new outbound call </span>
 var restCallUrl = String.Format(<span class="str">"/{0}/Accounts/{1}/Calls"</span>, ApiVersion, AccountSid);
 var parameters = <span class="kwrd">new</span> Hashtable
 {
 {<span class="str">"Caller"</span>, DovetailSupportCallerId},
 {<span class="str">"Called"</span>, phoneNumberToCall},
 {<span class="str">"Url"</span>, SupportDialerConversationUrl},
 {<span class="str">"Method"</span>, <span class="str">"GET"</span>}
 };
 var requestResult = account.request(restCallUrl, <span class="str">"POST"</span>, parameters);
 logger.Debug(requestResult);
}

All this really does is make a web request to Twilio’s Calls Rest
API giving it the number to call, the callerId of the number the call
should appear to come from, and the URL of the conversation script XML.

Scripting the Conversation

Once a call is in progress Twilio needs to know what to do. Twilio has an XML markup
for controlling what happens during a call. In our case all I want to
happen is that the support agent is made aware of a new urgent case so
this static XML does the trick.

<?xml version=<span class="str">"1.0"</span> encoding=<span class="str">"UTF-8"</span> ?>
<Response>
 <Say loop=<span class="str">"3"</span>>There <span class="kwrd">is</span> a <span class="kwrd">new</span> urgent or high priority support <span class="kwrd">case</span>. Please check Dovetail mobile.</Say>
</Response>

If we wanted to we could do more. Have the script Say details of the case to or allow the agent to Dial the customer contact immediately.

Wrap Up

I am very impressed with Twilio. Given my use case was very simple I
went from knowing nothing about Twilio to having an integration with
our enterprise CRM completed in about 3 hours doing everything from
getting an account setup and charged to leveraging their example code
and integrating it with our business processes. Their website is a
great resource for learning how to use the Twilio service with plenty
of examples to get you going.

Looking at the 5 primary verbs Say, Play, Gather, Record, and Dial
has my brain spinning with ideas for where we could be using Twilio to
create great customer experiences when the web is just not good enough.

Minor Complaint and or Suggestion

It would be nice if Twilio provided a way when invoking their Calls
Rest API to specify a static conversation script. It was weird to have
to host a static file on a web site just to have the call say something
to the receiver. [Thanks for your suggestion Kevin, we’ll be picking your brain about this and other things, and can’t wait to see what you cook up next!]

View original post