Part 3: Conversations, Messages, and Messages with attachments using RingCentral API

Vinay S
4 min readApr 18, 2023

--

In our previous story, we saw how to generate a Bearer token using RingCentral’s clientId & clientSecret in order to access all RC’s REST API. If you haven’t seen Part 2 — Please have a look & continue with Part 3

# Part 3: Conversations, Messages, Messages with Attachment.

First, let's try to hit any API available at Teams-Messaging module https://developers.ringcentral.com/api-reference/team-messaging

Endpoint:

https://platform.devtest.ringcentral.com/team-messaging/v1/conversations [GET]

Headers:

Authorization -> Bearer <generate bearer token from part 2>

Our first API call to the RingCentral — Teams Message module is working. Though you get dependency errors in the response, we are still able to make our request to reach RC’s server.

If you cross look at the error message it’s saying the credentials we are trying to use do not have an account with Glip. Wait, what is Glip here? — Simple, It's an RC’s messaging application name. Now all you have to do is just log in to http://app.devtest.ringcentral.com/ with the same admin account credentials.

Thats it. Now RingCentral automatically creates your user profile in Glip -> and is able to communicate with API/other users as part of the RingCentral network.

Now let's retry the same API call once again.

https://platform.devtest.ringcentral.com/team-messaging/v1/conversations [GET]

Now our API call is pulling all the conversation data from the account and getting the same in response.

Conversations:

In order to chat with any active/nonregistered user -> we have to first initiate and conversation by the following endpoint. Then the user will be notified via email -> if he is not having an account at RingCentral.

Once a conversation is created we will get “id” in response is called as chatId. In order to communicate between 2 parties we need chatId [id].

Ref: https://developers.ringcentral.com/api-reference/Conversations/createGlipConversationNew

Endpoint:

https://platform.devtest.ringcentral.com/team-messaging/v1/conversations [POST]

Headers:

Authorization -> Bearer <generate bearer token from part 2>

Body:

{“members”:[{“email”:”invitation@gmail.com”}]}

Pls Note: Noticed app.devtest.ringcentral.com intermittently not sending invitations to the email id.

You can also see the status of the invited user in the “Contacts” menu with the activation status from https://app.devtest.ringcentral.com

Posts: (Chat)

To post a message to any member, as we described above we need chatId from the Conversation endpoint. Once we have “chatId” we can make use of the Posts module endpoint to send a message

Ref: https://developers.ringcentral.com/api-reference/Posts/createGlipPostNew

Endpoint:

https://platform.devtest.ringcentral.com/team-messaging/v1/chats/<chatId>/posts [POST]

Headers:

Authorization -> Bearer <generate bearer token from part 2>

Body:

{“text”:”hello this is test”}

Great! We successfully sent the message from RC API.

Now let's try to send some files along with messages. For that, you to first upload the file to RC server and then while posting you have to send fileId.

Endpoint:

https://platform.devtest.ringcentral.com/team-messaging/v1/files [POST]

Headers:

Authorization -> Bearer <generate bearer token from part 2>

Body:

Now let’s make Post API call with fileId in the request body.

You can pull up all the messages under Post’s -> List Posts endpoint

To summarize, in In order to send messages between parties, first, we need to create a Conversation -> generate chatId using Conversation EndPoint. Once chatId is generated, we can send/receive a message via chatId using Post’s Endpoint.

Ref: https://developers.ringcentral.com/api-reference/Posts/readGlipPostNew

In our next chapter we will look for WebSocket -> to listen for live streaming of messages.

Thanks!

Build a communication app with RingCentral API [REST]

4 stories

--

--