Skip to main content
Question

Outbound Messages - Instant Message Event

  • October 14, 2021
  • 5 replies
  • 770 views

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?


5 replies

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • 2312 replies
  • October 15, 2021

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


  • Author
  • New Participant
  • 1 reply
  • October 19, 2021

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



  • Known Participant
  • 11 replies
  • February 16, 2023

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!


  • Known Participant
  • 11 replies
  • February 16, 2023

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.


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • 2312 replies
  • February 16, 2023

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',

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings