At Zenkraft we like to experiment and find new ways to integrate our solutions with other cloud products. This time, we had fun researching and writing code around Twilio, a cloud communication platform.
One of the great features of Twilio is that makes it easy to add voice to your application. For this reason, we thought it’d be valuable if we could integrate this with our shipping apps for Salesforce, and allow users to get shipment status updates by calling a phone number.
We wanted to share with you an easy step-by-step process of how you could setup your own look up shipment status with Twilio voice. First of all, you’d know that you can allow customers to find shipment status from an inbound number from any object. For this particular example, we’ve integrated with a Case.
- Ensure Shipmate is installed in your Salesforce org and integrated with a Case.
- Create a new VisualForce page (Setup > Develop > VisualForce Pages) that will handle the interaction with the Twilio API. Call it “TwilioPage” and add this code to it:
- Create a Force.com site (Setup > Develop > Sites) to expose a public URL
For our test, we exposed this URL “request URL”
Make sure that you put your VisualForce page we created earlier -called TwilioPage– into the Active Site Home Page section of this site:
- Don’t forget to activate this site by clicking on the Activate button.
- All the required Salesforce code for this demo app can be found here: https://github.com/zenkraft/TwilioShippingTracking
- Create a Twilio account – free account to get started.
- Create a phone number – local number.
- Under your new phone number in Twilio, click on tools and create a new TwiML App. For the requested URL, enter your force.com page that you created earlier
- The public URL should be called by Twilio when * is pressed.
- The apex handler should use SOQL to query Cases to find the matching case and return the tracking description:
The Twilio docs we used to build this demo are found here: https://www.twilio.com/docs/api/twiml/gather
We also uploaded Sample Code on GitHub for you to test this feature. Sample code available here: https://github.com/zenkraft/TwilioShippingTracking