1. Home
  2. Docs
  3. Developer Guide
  4. Twilio Voicemail Setup in Flexie CRM

Twilio Voicemail Setup in Flexie CRM

Voicemail is the technique that allows a caller leave a recorded message to you when you don’t answer the phone. You can listen to that message later and avoid loosing calls.

If you have a Twilio account already, integrated with Flexie CRM, there are some configuration steps to successfully setup your Voicemail system.

Note: If you don’t have a Twilio phone integrated then you can learn more about how to configure Twilio phone in Flexie CRM.

Voicemail configuration steps in Twilio

Login to your Twilio account and click on All Products & Services. It will open the main menu from where you can go to DEVELOPER TOOLS and click on Runtime menu option.

This will open the Runtime Menu where you will configure two Twilio bins

TwiML Bins allow developers create TwiML documents. TwiML documents are set of verbs and nouns hosted by Twilio and executed in response to incoming phone calls or SMS.

Click on TwiML Bins and create the first TwiML application which will have a text that Twilio will automatically translate to speech. This is what the caller will listen when you will not answer the call.

Click Create to create the application. If you check closer the configuration, the timeout is the number of seconds to wait before firing the voicemail and the action is a Dynamic Endopoint in Flexie CRM. This is useful to store call related information in Flexie CRM.

When you click on Create the TwiML application will generate a URL and a SID.

https://handler.twilio.com/twiml/[Auto generated SID for Call Message App]

Then you go ahead and create another second TwiML application which will handle the hang up.

Then navigate to Functions and create a new function. Set a name and in the last part of Function Path write  /voicemail as shown in the image below.

In the Configuration/Code section write the following code:

/**
 *  Voicemail Action URL
 * 
 *  This Function is used in as the action URL in a Dial. If the call isn't answered or the line is busy, 
 *  the call is forwarded to a specified Voicemal URL.
 */

exports.handler = function(context, event, callback) {
  // set-up the variables 
  // generate the TwiML to tell Twilio how to forward this call
  let twiml = new Twilio.twiml.VoiceResponse();

  if (event.DialCallStatus === "completed") {
    twiml.hangup();
  }
  else {
    twiml.redirect('https://handler.twilio.com/twiml/[Auto generated SID for Call Message App]');
  }
  // return the TwiML
  callback(null, twiml);
};

Note: The complete Function Path will be configured in Flexie CRM when you navigate to Settings -> Twilio Phone -> Account

Click Edit and paste the Function Path in Incoming Call Failure URL in Flexie CRM. You can also set the Incoming Call Timeout to your preference.

This function will trigger the first TwiML application you created and the voice message will be played to the caller.

The caller will leave a voice message and the information will be posted in the TwiML action URL where you will have the Dynamic Endpoint URL.

In Flexie CRM we can save the information we received from Twilio to a Custom Entity by using the Workflow Engine. Some of the most important information is the RecordingUrl, Called, To, RecordingDuration etc.

Voicemail is very important so you don’t loose any call that is made to your Twilio number and have all the necessary statistics inside Flexie.

To stay updated with the latest features, news and how-to articles and videos, please join our group on Facebook, Flexie CRM Academy and subscribe to our YouTube channel Flexie CRM.



How can we help?