Messaging

Access the Messaging API. You can instantiate a Messaging.Client to send or receive SMS and MMS. Please check Messaging.MessagingClientApiEvents for the full list of events that a Messaging.Client can subscribe to.

Example

The following example listens for incoming SMSs over an "office" context, and also sends an SMS.

const client = new Messaging.Client({
  project: "<project-id>",
  token: "<api-token>",
  contexts: ['office']
})

client.on('message.received', (message) => {
  console.log('message.received', message)
})

await client.send({
  from: '+1xxx',
  to: '+1yyy',
  body: 'Hello World!'
})

Interfaces

Type aliases

MessagingMessageState

Ƭ MessagingMessageState: "queued" | "initiated" | "sent" | "delivered" | "undelivered" | "failed"

The state a message can be in.

  • queued: The message has been queued in Relay.
  • initiated: Relay has initiated the process of sending the message.
  • sent: Relay has sent the message.
  • delivered: The message has been successfully delivered. Due to the nature of SMS and MMS, receiving a delivered event is not guaranteed, even if the message is delivered successfully.
  • undelivered: The message has not been delivered. Due to the nature of SMS and MMS, receiving a undelivered event is not guaranteed, even if the message fails to be delivered.
  • failed: The request has failed.