question

Pau Rodriguez avatar image
Pau Rodriguez asked Phong Vu commented

Outbound Messages - Instant Message Event

Is there a way to have outbound messages with the Instant Message Event? The payload example has a direction, but it seems this is only working for inbound.

If this is not the appropriate webhook, can someone point me to the correct event to have instant outbound messages?


getting started
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered Chady Boutros commented

Unfortunately, outbound message notification does not include the message payload, nor the "from" and "to" info. What is your use case?

2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Chady Boutros avatar image Chady Boutros commented ·

Hi Mr. @Phong Vu ,

We are only receiving the webhook for inbound messages and there is no webhook call for outbound messages. Could you please suggest if there is a way to listen to outbound message events?


Any help is highly appreciated.


Thanks!

0 Likes 0 ·
Chady Boutros avatar image Chady Boutros commented ·

The only way we know how to do this is by running a job that checks to see if the message is sent ever minute. Is there not a better way? That solution is not ideal.

We are building a CRM system where we send and receive texts to our clients from the system. We have no problems receiving the texts. Our problem is that we can't confirm if something is sent without running a job every minute.

Please advise us on the best way to proceed. If we have to run the job ever minute, we can. We just want a better way if it is possible. Thank you in advance.

0 Likes 0 ·
Pau Rodriguez avatar image
Pau Rodriguez answered

Hi Phong,

We were trying to get all the SMS messages to ingest those in another system, we were taking a look, and we decide to use that event, as the payload had direction as a parameter, we were thinking Inbound and Outbound should be the values, but it seems only works for Inbound. After that, we decided to get Inbound with that event and Outbound with message-store?type=SMS&direction=Outbound and then get the Message ID and do an API call to getMessges to have the text of the messages + from and to.

Do you know, for instant message events if there is another value for direction?


Thanks


1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered Phong Vu commented

Here is how you can get notified for both inbound and outbound new text message events

var eventFilters = ['/restapi/v1.0/account/~/extension/~/message-store?type=SMS']

// E.x using PubNub notification
subscription.on(subscription.events.notification, async function(msg) {
    for (var message of msg.body.changes){
      for (var msgId of message.newMessageIds){
        await readMessageDetail(msgId)
      }
    }
});

async function readMessageDetail(msgId){
  try{
    var resp = await platform.get(`/restapi/v1.0/account/~/extension/~/message-store/${msgId}`)
    var jsonObj = await resp.json()
    console.log(JSON.stringify(jsonObj)
  }catch(e){
    console.log(e.message)
  }
}

Alternative way to get inbound text message with message detailed in the event body, and, you can subscribe for separate events as follows:

'/restapi/v1.0/account/~/extension/244609004/message-store/instant?type=SMS'
'/restapi/v1.0/account/~/extension/233723004/message-store?direction=Outbound&type=SMS',
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Andrey Elenskiy avatar image Andrey Elenskiy commented ·

where did you get the new message ids?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Andrey Elenskiy commented ·

Why don't you try it yourself? Look at the following code to see how to get it.

for (var message of msg.body.changes){
   for (var msgId of message.newMessageIds){
       await readMessageDetail(msgId)
   }
}
0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys