Skip to content

Commit

Permalink
Merge pull request #44 from tecoad/main
Browse files Browse the repository at this point in the history
  • Loading branch information
tecoad authored Aug 13, 2024
2 parents 1b205f5 + 68fba65 commit 782d62e
Showing 1 changed file with 73 additions and 32 deletions.
105 changes: 73 additions & 32 deletions src/types/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ type SharedMessageTypes = Exclude<MessageType, "template">;

/**
* For more information about this object, go here https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#messages-object
*
* Please also take a look at the examples for this object, because the docs for this object are not always up to date.
*
* Please also take a look at the examples for this object, because the docs for this object are not always up to date.
* You can find the examples for this object here https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/payload-examples#received-messages
*/
export type WebhookMessage = {
Expand Down Expand Up @@ -182,40 +182,81 @@ export type WebhookMessage = {
* */
image?: WebhookMedia;
/**
* When a customer selected a button or list reply.
* Included when a customer interacts with an interactive message (button, list, or flow).
*/
interactive?: {
type: string;
/**
* Sent when a customer clicks a button
* The type of interactive message that the customer replied to.
*/
button_reply?: {
/**
* Unique ID of a button
*/
id: string;
title: string;
};
/**
* Sent when a customer selects an item from a list
*/
list_reply?: {
/**
* Unique ID of the selected list item
*/
id: string;
title: string;
description: string;
};
/**
* Sent when a user submits a flow
*/
nfm_reply?: {
body: string;
name: string;
response_json: string;
};
};
type: "button_reply" | "list_reply" | "nfm_reply";
} & (
| {
type: "button_reply";
/**
* Sent when a customer clicks a button.
*/
button_reply: {
/**
* Unique ID of the button.
*/
id: string;
/**
* Title of the button.
*/
title: string;
};
}
| {
type: "list_reply";
/**
* Sent when a customer selects an item from a list.
*/
list_reply: {
/**
* Unique ID of the selected list item.
*/
id: string;
/**
* Title of the selected list item.
*/
title: string;
/**
* Description of the selected list item.
*/
description: string;
};
}
| {
type: "nfm_reply";
/**
* Sent when a user submits a flow.
*/
nfm_reply:
| {
name: "address_message";
body?: string;
response_json: string;
}
| {
/**
* Indicates a general flow submission.
* Documentation: https://developers.facebook.com/docs/whatsapp/flows/reference/responsemsgwebhook/
*/
name: "flow";
/**
* Body text indicating the flow was sent.
*/
body: "Sent";
response_json: string;
}
| {
name?: string;
body?: string;
response_json: string;
};
}
);

/**
* When the messages type field is set to location, this object is included in the messages object:
*/
Expand Down

0 comments on commit 782d62e

Please sign in to comment.