VoicePulse Blog

Connect your phones to Zendesk, Salesforce, Slack, Hipchat... or anything else with an API!

In our Introducing CallCode post, we announced that CallCode lets you integrate your phone calls with any service that provides a webhook or API. In this post, we'll look at that a little more in-depth with an example that allows you to query your Zendesk installation to identify high-priority customers and post a message to Slack when they call you.

If you don't already have a VoicePulse FIVE account, click here to register for free.

Your first stop for writing CallCode apps should be our GitHub repository. We have sample code you can paste into your CallCode editor and start using right away, as well as a brief introduction to writing your own CallCode apps. In fact if you're experienced with writing Node.js code, you can probably start writing your own CallCode app just based on the info we have in GitHub.

For this post, let's take a look at the ZendeskContactToSlack.js app - this is a great example because it integrates two different services at once, Zendesk CRM and Slack team messaging. First, it looks for a contact in Zendesk whose phone number matches the caller's caller-id. If there are any results, it picks the first one and sends an alert to Slack to notify you that you're receiving a phone call from that customer.  You can easily modify the code to only notify you when the customer has a certain tag assigned to them in Zendesk -- this is how you can filter calls so only high-priority customers generate a Slack notification.

Within the CallCode app, you can do anything you'd normally expect to do in Node.js including writing functions and importing any of the core Node.js modules. (We'll make additional modules available for import over time, and you can send any suggestions to us via our Feature Requests page.) You can see this example uses the "https" module for making API calls, and the "querystring" module for constructing the Zendesk search.

The basic flow of ZendeskContactToSlack.js is as follows:

  • Pass the "from" phone number to the searchZendesk() function
  • Format that number for Zendesk search
  • Construct a Zendesk search - something like "type:user tags:custom_tag phone:*2125551212" - and send it to Zendesk's API
  • If there are 1 or more results, pass a message with the first result to notifySlack()
  • Post the notification message to your Slack Incoming Webhook

The only parts you need to customize are the all caps variables near the top, which contain Zendesk and Slack API information specific to your organization. But what if you don't use Slack? No problem! Just swap out the notifySlack function with your own custom code. Or, copy some code from a different example.

Take a look at NotifyZapier.js from the same GitHub repo. The main difference is that notifySlack() expects a string, whereas notifyZapier expects a JSON object. Once you've made that small change, your CallCode app now notifies Zapier instead of Slack.

Topics: Blog CallCode new features