import type * as Pinnacle from "../index.mjs";
/**
* Represents an incoming message or message status update received via webhook.
*/
export interface MessageEvent {
/** Type of webhook event. `MESSAGE.STATUS` for message status updates, `MESSAGE.RECEIVED` for inbound messages. */
type: MessageEvent.Type;
/** Conversation metadata containing the conversation ID, sender, and recipient information. */
conversation: MessageEvent.Conversation;
status: Pinnacle.MessageStatusEnum;
/** Direction of the message flow. */
direction: MessageEvent.Direction;
/** Number of segments for this message. */
segments: number;
/**
* Timestamp when the message was sent in ISO 8601 format.
* Null if the message has not been sent yet.
*/
sentAt: string | null;
/**
* Timestamp when the message was delivered in ISO 8601 format.
* Null if not yet delivered or for inbound messages.
*/
deliveredAt?: string | null;
message: Pinnacle.MessageEventContent;
/**
* The unique identifier of the original RCS message that this fallback SMS/MMS was sent on behalf of. Always begins with the prefix `msg_`.
*
* Only present on webhook events for fallback SMS/MMS messages. Use this to link the fallback back to the RCS message that could not be delivered. The `message.id` field on this event refers to the actual SMS/MMS that was sent — `originalMessageId` refers to the RCS message it replaced.
*
* Null when the message is not a fallback.
*/
originalMessageId?: string | null;
/**
* Details of the fallback SMS/MMS message(s) that were actually sent to the recipient instead of the original RCS message.
*
* Only present when the message `status` is `FALLBACK_SENT`. The `message.id` on this event refers to the original RCS message that could not be delivered. The `fallbackMessage.ids` contain the identifiers of the actual SMS/MMS messages that were sent.
*/
fallbackMessage?: MessageEvent.FallbackMessage | null;
}
export declare namespace MessageEvent {
/** Type of webhook event. `MESSAGE.STATUS` for message status updates, `MESSAGE.RECEIVED` for inbound messages. */
const Type: {
readonly MessageStatus: "MESSAGE.STATUS";
readonly MessageReceived: "MESSAGE.RECEIVED";
};
type Type = (typeof Type)[keyof typeof Type];
/**
* Conversation metadata containing the conversation ID, sender, and recipient information.
*/
interface Conversation {
/**
* Unique identifier for the conversation. This identifier is a string that always begins with the prefix `conv_`, for example: `conv_1234567890`.
* To get more conversation details, use the [POST /conversations/get](/api-reference/conversations/get) endpoint.
*/
id: string;
/** Sender's phone number or agent ID. */
from: string;
/** Recipient's phone number. */
to: string;
}
/** Direction of the message flow. */
const Direction: {
readonly Inbound: "INBOUND";
readonly Outbound: "OUTBOUND";
};
type Direction = (typeof Direction)[keyof typeof Direction];
/**
* Details of the fallback SMS/MMS message(s) that were actually sent to the recipient instead of the original RCS message.
*
* Only present when the message `status` is `FALLBACK_SENT`. The `message.id` on this event refers to the original RCS message that could not be delivered. The `fallbackMessage.ids` contain the identifiers of the actual SMS/MMS messages that were sent.
*/
interface FallbackMessage {
/**
* Unique identifiers of the actual SMS/MMS message(s) that were sent as the fallback. Each identifier always begins with the prefix `msg_`. Multiple IDs indicate the fallback was split into multiple SMS/MMS messages.
* These are the messages that were actually delivered to the recipient. To get their full details, use the [GET /messages/{id}](/api-reference/messages/get) endpoint.
*/
ids: string[];
/** Delivery protocol of the fallback message that was sent. */
type: FallbackMessage.Type;
/** Phone number the fallback message was sent from in E.164 format. */
from: string;
/** Recipient's phone number in E.164 format. */
to: string;
/** Text content of the fallback message. */
text?: string;
/** Media URLs included in the fallback MMS message. Empty array for SMS fallbacks. */
mediaUrls?: string[];
}
namespace FallbackMessage {
/** Delivery protocol of the fallback message that was sent. */
const Type: {
readonly Sms: "SMS";
readonly Mms: "MMS";
};
type Type = (typeof Type)[keyof typeof Type];
}
}