Bandwidth SMS and Voice Integration
Bandwidth is a cloud communication platform that provides API based integration of voice and sms features into business applications. Here at Botsplash, we integrated Bandwidth for our conversation platform, to allow agents and visitors to send/receive messages and make voice calls. This blog is a deep dive to share with you how we implemented Bandwidth integration.
Before we can begin, the first step is creating a Bandwidth account. Next, create new application by going to the Bandwidth dashboard and navigate to the Applications tab. To continue, note the API credentials namely userId, apiToken and apiSecret.
Our technology is NodeJS backend and hence have used their NodeJS SDK.The business use case for our platform is that Botsplash clients buy phone numbers and use the same for sending and receiving messages. The APIs we implemented are
- Search phone number based on area code
- Buy phone number
- Send SMS/MMS message
- Receive SMS/MMS message
Note: Depending of your specific use case, you might require any, all or more integrations.
Bandwidth client and methods
1. Search phone number based on area code
The first API we need is to allow users to search for available phone numbers.
This API will return 5 phone numbers in the given area code. We display the returned numbers to the user in the UI which they will be able to select in order to buy.
2. Buy phone number
This API will allow user to buy a number which the user selects from the previous search phone number API. It will take on the application Id and the phone number as payload body.
3. Send SMS/MMS message
This API will allow sending SMS or MMS message from the Bandwidth number that we purchased. For MMS, we simply need to send list of media urls in the payload body.
4. Receive SMS/MMS message
Bandwidth provides option to add a webhook url in our Bandwidth application dashboard that will get triggered if an SMS/MMS is received to any number attached to the application. We will need to build this webhook url that can listen to messages received.
Response data received from Bandwidth to our webhook url:
The above endpoint will receive the message payload from Bandwidth. We can have a function to parse the attachments to store the media in different server as required which is what “getAttachments” function does. We then save the message received to the database.
Similar to the messages, voice call engagement and forwarding could be enabled using the bandwidth SDK. For complete set of capabilities and integration details, refer to the Calls API.
Hope you have enjoyed this post and found it useful. It is very encouraging to read your comments and feedback, so please share in comments sections any thoughts you may have.
For more articles on Live Chat, Automated Bots, SMS Messaging and Conversational Voice solutions, explore our blog.