Scheduling and Automating Text Notification: Mulesoft and RingCentral

DZone 's Guide to

Scheduling and Automating Text Notification: Mulesoft and RingCentral

Learn how to combine the polling component in Mulesoft with the messaging API of RingCentral to automatically schedule SMS texting.

· Integration Zone ·
Free Resource

RingCentral, one of the amazing cloud communication provider provides different communication features with a simple setup such calling, messaging, faxing, and meetings, which can be used by users and their organization at enterprise scale for communication.

RingCentral actually deals with different kinds of APIs that offers reliable VoIP calling, web meetings, fax, and more features over cloud communication with reliability, security, and quality.

RingCentral, as we all know, provides a feature of sending SMS text messages via its API. You can send SMS messages simultaneously to different recipients, up to 50 requests per minute.

The API for sending SMS is here.

In most cases, we can build an application on top of this API and send SMS text messages to a real phone number. In the RingCentral community, what we have seen is that many developers have a requirement to have an automated SMS service that will be scheduled to trigger SMS to a certain phone number at a specific interval of time! 

You may also enjoy: Build a RingCentral Virtual Voicemail Assistant for Your Business   — Part 1

Well, in this post we will address that concern and see how we can create a simple application that will automate the RingCentral SMS service and trigger the message in a specific interval of time. 

Creating the Application

To create this application, we will use a Mulesoft application which will be a lightweight application and will be easy to use.

Mulesoft is a Java-based framework which help to create a lightweight, secure, reusable application that can integrate with any other application or API easily.

To create the application, we need to create a new Mulesoft application in Anypoint studio.

Creating a Mule Project

The next step is to create a flow that will trigger the SMS at a specific interval of time. 

To schedule an SMS for a particular time, we need a scheduler component that will be active and trigger the flow at a interval of time.

Fortunately, in Mulesoft we have a Poll component that will set to poll a flow in a specific interval of time:

Poll component

Now, we will create a flow that will send an SMS message to a phone number in an interval of time we will set. We will design the flow so it will call the RingCentral Create SMS API and pass the parameters such as "To Phone number," "From Phone number," and "Text message," as you can see below:


As you can see above, the poller is set a the beginning of the flow, which is scheduled to be active at a particular time, followed by parameters where we set the number where the SMS text will be sent. The text message and the number from where it will be send.

We can also see an HTTP component also present which will call the RingCentral Create SMS API and send the SMS.

When this is all set, we will design a sub-flow, that will call RingCentral Authorization API and generate the  access_token (since RingCentral Create SMS API is secured by Oauth and  access_token  is needed to send the SMS) as below:

Authorization API

As we can see, this sub-flow also has an HTTP component that calls RingCentral Authorization API and collect the  access_token in a variable. This  access_token variable will be internally passed to the RingCentral Create SMS API when we call that in our main flow (SendSMS).

Coming back to our main flow (SendSMS), we call this Oauth sub-flow before we call RingCentral Create SMS API to get the  access_token and send the SMS text as below:

Calling Oauth sub-flow

That's it! Now, every time the flow is triggered by the poller scheduler, the SMS message will be sent.

If we now deploy the application we can see the poller is activated at a specific interval of time and triggering the SMS flow which is sending SMS messages to the phone number at a regular interval via RingCentral Create SMS API in the logs below:

Activation time

We can see the text message in the phone number send, and even in the email attached with the phone number: 


Further Reading

mule ,ringcentral ,ringcentral apis ,sms ,polling component ,mulesoft ,integration

Published at DZone with permission of Anirban Sen Chowdhary , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}