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.


 private static void Main(string[] args)


      var logger = GetLogger();

      if(args.Length < 1 )


          const string message = "Could not dial number as no arguments were supplied";




      var phoneNumberToCall = args[0];

      logger.InfoFormat("Calling {0}.", phoneNumberToCall);

      // Create Twilio REST account object using Twilio account ID and token

      var account = new Account(AccountSid, AccountToken);

      // Initiate a new outbound call 

      var restCallUrl = String.Format("/{0}/Accounts/{1}/Calls", ApiVersion, AccountSid);

      var parameters = new Hashtable


              {"Caller", DovetailSupportCallerId},

              {"Called", phoneNumberToCall},

              {"Url", SupportDialerConversationUrl},

              {"Method", "GET"}


      var requestResult = account.request(restCallUrl, "POST", parameters);




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="1.0" encoding="UTF-8" ?  


      Say loop="3"There is a new urgent or high priority support case. Please check Dovetail mobile./Say  



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.