{{announcement.body}}
{{announcement.title}}

Messaging APIs of RingCentral

DZone 's Guide to

Messaging APIs of RingCentral

In this article, we will discuss the different APIs related to SMS and messaging.

Free Resource

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

In this article, we will discuss the different APIs related to SMS and messaging and it’s various status.

As we have already seen in our previous posts, we can start by logging into our RingCentral developer portal, and all we need to do is create a new application by hitting the CreateApp button in the top right:

This image has an empty alt attribute; its file name is image-15.png

The following details need to be provided:

  • Application Name: The name of your app.
  • Organization Name: The name of your organization.
  • Description: Any text describing your app and should contain a minimum of 20 characters.

We have chosen Desktop (Mac/Windows/Other), and authorization includes password flow in the above image. Once the API is created, we can see details like client id, client secret, etc. in the dashboard:

This image has an empty alt attribute; its file name is image-17.png

Testing API via Postman

Creates and sends a new message: You can send SMS messages simultaneously to different recipients up to 50 requests per minute.

The API for sending SMS is:

POST https://platform.devtest.ringcentral.com/restapi/v1.0/account/accountId/extension/extensionId/sms

If you see the messageStatus here, it is queued:

If the status for at least one recipient is ‘Queued‘, then ‘Queued‘ value is returned, which means the message hasn’t reached the SMS provider. If the SMS provider is temporarily unavailable, the message will be ‘Queued‘ and the carrier will continue to retry.

Reading the message status: Every message we send has a message id. We can read the message state by using the following API:

GET https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-store/<message id>

By this time, if you check the message state, it will show ‘Delivered’ as above, which means the message has reached the recipient.

If the mobile phone we are sending is switched off, the carrier will try to deliver within 48 hours, and if unsuccessful, then the message will expire, and in that case, we will get the status as ‘DeliveryFailed‘.

Deleting the message: We can use the same API to delete the message. For example, if we use the DELETE method as follows:

DELETE https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-store/<message id>

The API has deleted the message from the message store. It will not provide any response.

Now if we do a GET and check the response, we will see: availability is ‘Deleted‘ :

Message availability status. Message in ‘Deleted‘ state is still preserved with all its attachments and can be restored.

Modifying readStatus of message: We can use the same API with the PUT method and modify the readstatus of the message. There are 2 readStatus: Read, Unread

We can modify as below:

PUT https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-store/<message id>

As we can see above, we have modified the SMS readStatus into unread.

If we go back to the previous API of Reading the message status, GET https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-store/<message id> and check the readStatus of the message, we will get the below:

Listing Valid SMS Numbers: To determine which numbers a user can use to send and receive an SMS, retrieve the user’s list of phone numbers from the extension/phone-number endpoint and then filter by numbers with the SmsSender and/or MmsSenderfeature.

Reading SMS Content: Last but not least, we can also read the actual message or SMS content and see what the user had sent using the following API:

GET https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-store/<message id>/content/<attachment id>

Conclusion

So, we can see that RingCentral not only provides an API to just send an SMS message, but it also provides APIs the ability to get SMS statuses, content, and even the ability to delete an SMS message, retrieve it, change its read status, and so on. It provides such a variety of features that we can actually control almost all the messaging features.

We can integrate all these features of the API in our application, which can be a web application or an android or even a standalone running in any programming language, such as Java, PHP, javascript, etc. and control all the messaging features in a single place.

Topics:
ringcentral ,ringcentral apis ,integration ,tutorial ,messaging apis

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 }}