From bdcbccd364b4a2b468f6f0e5a57aa9e601013e2d Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Fri, 29 Mar 2024 16:51:30 +0100 Subject: [PATCH] Align Conversation SDK with documentation --- .../src/models/v1/app-message/app-message.ts | 8 +++- .../channel-specific-contact-message.ts | 21 +++++++++ .../channel-specific-contact-message/index.ts | 1 + .../channel-specific-message.ts | 11 +++++ .../v1/channel-specific-message/index.ts | 1 + .../v1/contact-message/contact-message.ts | 45 ++++++++++++++++++- .../delivery-report-based-fallback.ts | 10 ++++- packages/conversation/src/models/v1/enums.ts | 9 ++-- .../flow-channel-specific-message.ts | 44 ++++++++++++++++++ .../v1/flow-channel-specific-message/index.ts | 1 + packages/conversation/src/models/v1/index.ts | 13 ++++++ .../models/v1/list-section/list-section.ts | 2 +- .../message-retry-settings.ts | 2 +- .../src/models/v1/product-item/index.ts | 1 + .../models/v1/product-item/product-item.ts | 15 +++++++ .../v1/product-response-message/index.ts | 1 + .../product-response-message.ts | 13 ++++++ .../v1/whatsapp-interactive-body/index.ts | 1 + .../whatsapp-interactive-body.ts | 7 +++ .../index.ts | 1 + .../whatsapp-interactive-document-header.ts | 11 +++++ .../v1/whatsapp-interactive-footer/index.ts | 1 + .../whatsapp-interactive-footer.ts | 7 +++ .../index.ts | 1 + .../whatsapp-interactive-header-media.ts | 7 +++ .../index.ts | 1 + .../whatsapp-interactive-image-header.ts | 11 +++++ .../whatsapp-interactive-nfm-reply/index.ts | 1 + .../whatsapp-interactive-nfm-reply.ts | 11 +++++ .../whatsapp-interactive-text-header/index.ts | 1 + .../whatsapp-interactive-text-header.ts | 9 ++++ .../index.ts | 1 + .../whatsapp-interactive-video-header.ts | 11 +++++ .../src/rest/v1/contact/contact-api.ts | 4 +- .../rest/v1/conversation/conversation-api.ts | 11 ++--- .../src/rest/v1/events/events-api.ts | 3 +- 36 files changed, 280 insertions(+), 18 deletions(-) create mode 100644 packages/conversation/src/models/v1/channel-specific-contact-message/channel-specific-contact-message.ts create mode 100644 packages/conversation/src/models/v1/channel-specific-contact-message/index.ts create mode 100644 packages/conversation/src/models/v1/channel-specific-message/channel-specific-message.ts create mode 100644 packages/conversation/src/models/v1/channel-specific-message/index.ts create mode 100644 packages/conversation/src/models/v1/flow-channel-specific-message/flow-channel-specific-message.ts create mode 100644 packages/conversation/src/models/v1/flow-channel-specific-message/index.ts create mode 100644 packages/conversation/src/models/v1/product-item/index.ts create mode 100644 packages/conversation/src/models/v1/product-item/product-item.ts create mode 100644 packages/conversation/src/models/v1/product-response-message/index.ts create mode 100644 packages/conversation/src/models/v1/product-response-message/product-response-message.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-body/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-body/whatsapp-interactive-body.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-document-header/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-document-header/whatsapp-interactive-document-header.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-footer/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-footer/whatsapp-interactive-footer.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-header-media/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-header-media/whatsapp-interactive-header-media.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-image-header/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-image-header/whatsapp-interactive-image-header.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/whatsapp-interactive-nfm-reply.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-text-header/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-text-header/whatsapp-interactive-text-header.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-video-header/index.ts create mode 100644 packages/conversation/src/models/v1/whatsapp-interactive-video-header/whatsapp-interactive-video-header.ts diff --git a/packages/conversation/src/models/v1/app-message/app-message.ts b/packages/conversation/src/models/v1/app-message/app-message.ts index 6d14e2ed..bc0414fa 100644 --- a/packages/conversation/src/models/v1/app-message/app-message.ts +++ b/packages/conversation/src/models/v1/app-message/app-message.ts @@ -10,6 +10,7 @@ import { CarouselMessage, CarouselMessageItem } from '../carousel-message'; import { ListMessage, ListMessageItem } from '../list-message'; import { ContactInfoMessage, ContactInfoMessageItem } from '../contact-info-message'; import { ConversationChannel } from '../conversation-channel'; +import { ChannelSpecificMessage } from '../channel-specific-message'; /** * Message originating from an app @@ -153,7 +154,7 @@ interface AppContactInfoMessage extends AppMessageBase { interface AppMessageBase { /** - * Optional. Channel specific messages, overriding any transcoding. + * Channel specific messages, overriding any transcoding. * The key in the map must point to a valid conversation channel as defined by the enum ConversationChannel. */ explicit_channel_message?: { [key in ConversationChannel ]?: string; }; @@ -162,6 +163,11 @@ interface AppMessageBase { * (for channels on which channel-specific templates can be created. For more information, see [Channel Specific Templates](https://developers.sinch.com/docs/conversation/templates/#channel-specific-templates)). */ explicit_channel_omni_message?: { [key in ChannelSpecificTemplate]?: OmniMessage; }; + /** + * Channel specific messages, overriding any transcoding. The structure of this property is more well-defined than the open structure of the `explicit_channel_message` property, and may be easier to use. + * The key in the map must point to a valid conversation channel as defined in the enum `ConversationChannel`. + */ + channel_specific_message?: { [key in ConversationChannel]?: ChannelSpecificMessage; }; /** Identity of a sender */ agent?: Agent | null; } diff --git a/packages/conversation/src/models/v1/channel-specific-contact-message/channel-specific-contact-message.ts b/packages/conversation/src/models/v1/channel-specific-contact-message/channel-specific-contact-message.ts new file mode 100644 index 00000000..b21f0f0e --- /dev/null +++ b/packages/conversation/src/models/v1/channel-specific-contact-message/channel-specific-contact-message.ts @@ -0,0 +1,21 @@ +import { WhatsAppInteractiveNfmReply } from '../whatsapp-interactive-nfm-reply'; + +/** + * A contact message containing a channel specific message (not supported by OMNI types). + */ +export interface ChannelSpecificContactMessage { + /** The message type. */ + message_type: 'nfm_reply'; + /** @see WhatsAppInteractiveNfmReplyMessage */ + message: WhatsAppInteractiveNfmReplyMessage; +} + +/** + * A WhatsApp interactive contact message containing the nfm_reply. + */ +interface WhatsAppInteractiveNfmReplyMessage { + /** The interactive message type. */ + type: string; + /** @see WhatsAppInteractiveNfmReply */ + nfm_reply: WhatsAppInteractiveNfmReply; +} diff --git a/packages/conversation/src/models/v1/channel-specific-contact-message/index.ts b/packages/conversation/src/models/v1/channel-specific-contact-message/index.ts new file mode 100644 index 00000000..5718768c --- /dev/null +++ b/packages/conversation/src/models/v1/channel-specific-contact-message/index.ts @@ -0,0 +1 @@ +export type { ChannelSpecificContactMessage } from './channel-specific-contact-message'; diff --git a/packages/conversation/src/models/v1/channel-specific-message/channel-specific-message.ts b/packages/conversation/src/models/v1/channel-specific-message/channel-specific-message.ts new file mode 100644 index 00000000..a80b3269 --- /dev/null +++ b/packages/conversation/src/models/v1/channel-specific-message/channel-specific-message.ts @@ -0,0 +1,11 @@ +import { FlowChannelSpecificMessage } from '../flow-channel-specific-message'; + +/** + * A message containing a channel specific message (not supported by OMNI types). + */ +export interface ChannelSpecificMessage { + /** @see MessageTypeEnum */ + message_type: 'FLOWS'; + /** @see FlowChannelSpecificMessage */ + message: FlowChannelSpecificMessage; +} diff --git a/packages/conversation/src/models/v1/channel-specific-message/index.ts b/packages/conversation/src/models/v1/channel-specific-message/index.ts new file mode 100644 index 00000000..c33e13eb --- /dev/null +++ b/packages/conversation/src/models/v1/channel-specific-message/index.ts @@ -0,0 +1 @@ +export type { ChannelSpecificMessage } from './channel-specific-message'; diff --git a/packages/conversation/src/models/v1/contact-message/contact-message.ts b/packages/conversation/src/models/v1/contact-message/contact-message.ts index 9291c4c4..52814b67 100644 --- a/packages/conversation/src/models/v1/contact-message/contact-message.ts +++ b/packages/conversation/src/models/v1/contact-message/contact-message.ts @@ -5,6 +5,8 @@ import { MediaCardMessage } from '../media-card-message'; import { MediaMessageItem } from '../media-message'; import { ReplyTo } from '../reply-to'; import { TextMessageItem } from '../text-message'; +import { ProductResponseMessage } from '../product-response-message'; +import { ChannelSpecificContactMessage } from '../channel-specific-contact-message'; /** * Message originating from a contact @@ -15,16 +17,34 @@ export type ContactMessage = | ContactMessageLocationMessage | ContactMessageMediaCardMessage | ContactMessageMediaMessage - | ContactMessageTextMessage; + | ContactMessageTextMessage + | ContactMessageProductResponseMessage + | ContactMessageChannelSpecificContactMessage; + +interface ContactMessageChannelSpecificContactMessage extends ContactMessageBase { + /** @see ChannelSpecificContactMessage */ + channel_specific_message: ChannelSpecificContactMessage; + // Exclude other message types + choice_response_message?: never; + fallback_message?: never; + location_message?: never; + media_card_message?: never; + media_message?: never; + product_response_message?: never; + text_message?: never + +} interface ContactMessageChoiceResponseMessage extends ContactMessageBase { /** @see ChoiceResponseMessage */ choice_response_message: ChoiceResponseMessage; // Exclude other message types + channel_specific_message?: never; fallback_message?: never; location_message?: never; media_card_message?: never; media_message?: never; + product_response_message?: never; text_message?: never } @@ -32,10 +52,12 @@ interface ContactMessageFallbackMessage extends ContactMessageBase { /** @see FallbackMessage */ fallback_message: FallbackMessage; // Exclude other message types + channel_specific_message?: never; choice_response_message?: never; location_message?: never; media_card_message?: never; media_message?: never; + product_response_message?: never; text_message?: never; } @@ -43,10 +65,12 @@ interface ContactMessageLocationMessage extends ContactMessageBase { /** @see LocationMessageItem */ location_message: LocationMessageItem; // Exclude other message types + channel_specific_message?: never; choice_response_message?: never; fallback_message?: never; media_card_message?: never; media_message?: never; + product_response_message?: never; text_message?: never; } @@ -54,10 +78,12 @@ interface ContactMessageMediaCardMessage extends ContactMessageBase { /** @see MediaCardMessage */ media_card_message: MediaCardMessage; // Exclude other message types + channel_specific_message?: never; choice_response_message?: never; fallback_message?: never; location_message?: never; media_message?: never; + product_response_message?: never; text_message?: never; } @@ -65,21 +91,38 @@ interface ContactMessageMediaMessage extends ContactMessageBase { /** @see MediaMessageItem */ media_message: MediaMessageItem; // Exclude other message types + channel_specific_message?: never; choice_response_message?: never; fallback_message?: never; location_message?: never; media_card_message?: never; + product_response_message?: never; text_message?: never; } +interface ContactMessageProductResponseMessage extends ContactMessageBase { + /** @see ProductResponseMessage */ + product_response_message: ProductResponseMessage + // Exclude other message types + channel_specific_message?: never; + choice_response_message?: never; + fallback_message?: never; + location_message?: never; + media_card_message?: never; + media_message?: never; + text_message?: never +} + interface ContactMessageTextMessage extends ContactMessageBase { /** @see TextMessageItem */ text_message: TextMessageItem; // Exclude other message types + channel_specific_message?: never; choice_response_message?: never; fallback_message?: never; location_message?: never; media_card_message?: never; + product_response_message?: never; media_message?: never; } diff --git a/packages/conversation/src/models/v1/delivery-report-based-fallback/delivery-report-based-fallback.ts b/packages/conversation/src/models/v1/delivery-report-based-fallback/delivery-report-based-fallback.ts index 20ea44b4..5c2bc767 100644 --- a/packages/conversation/src/models/v1/delivery-report-based-fallback/delivery-report-based-fallback.ts +++ b/packages/conversation/src/models/v1/delivery-report-based-fallback/delivery-report-based-fallback.ts @@ -4,8 +4,14 @@ */ export interface DeliveryReportBasedFallback { - /** Optional. A flag specifying whether this app has enabled fallback message delivery upon no positive delivery report. This feature is applicable only to messages which are sent to a recipient with more than one channel identity. Identities must be defined on channels which support at least the \'DELIVERED\' message state. **Please note that this functionality requires payment.** */ + /** + * Optional. A flag specifying whether this app has enabled fallback message delivery upon no positive delivery report. + * This feature is applicable only to messages which are sent to a recipient with more than one channel identity. + * Identities must be defined on channels which support at least the 'DELIVERED' message state. + * **Please note that this functionality requires payment.** */ enabled?: boolean; - /** Optional. The time, in seconds, after which a message without a positive delivery report will fallback to the next channel. The valid values for this field are [60 - 259200]. */ + /** + * Optional. The time, in seconds, after which a message without a positive delivery report will fallback to the next channel. + * The valid values for this field are [60 - 259200]. */ delivery_report_waiting_time?: number; } diff --git a/packages/conversation/src/models/v1/enums.ts b/packages/conversation/src/models/v1/enums.ts index 1a57f48b..e715ca56 100644 --- a/packages/conversation/src/models/v1/enums.ts +++ b/packages/conversation/src/models/v1/enums.ts @@ -1,8 +1,7 @@ -export type { - SentimentResult as MachineLearningSentimentEnum, - EvaluationEnum as OffensiveAnalysisEvaluationEnum, -} from './mod-callback-events/smart-conversations-event/smart-conversations-event'; - +/** + * NONE - Omit metadata. + * FULL - Include all metadata assigned to the conversation. + */ export type ConversationMetadataReportView = 'NONE' | 'FULL'; export type ConversationMetadataUpdateStrategy = 'REPLACE' | 'MERGE_PATCH'; diff --git a/packages/conversation/src/models/v1/flow-channel-specific-message/flow-channel-specific-message.ts b/packages/conversation/src/models/v1/flow-channel-specific-message/flow-channel-specific-message.ts new file mode 100644 index 00000000..76de7530 --- /dev/null +++ b/packages/conversation/src/models/v1/flow-channel-specific-message/flow-channel-specific-message.ts @@ -0,0 +1,44 @@ +import { WhatsAppInteractiveBody } from '../whatsapp-interactive-body'; +import { WhatsAppInteractiveFooter } from '../whatsapp-interactive-footer'; +import { WhatsAppInteractiveTextHeader } from '../whatsapp-interactive-text-header'; +import { WhatsAppInteractiveImageHeader } from '../whatsapp-interactive-image-header'; +import { WhatsAppInteractiveDocumentHeader } from '../whatsapp-interactive-document-header'; +import { WhatsAppInteractiveVideoHeader } from '../whatsapp-interactive-video-header'; + +/** + * A message type for sending WhatsApp Flows. + */ +export interface FlowChannelSpecificMessage { + + /** @see FlowChannelSpecificMessageHeader */ + header?: FlowChannelSpecificMessageHeader; + /** @see WhatsAppInteractiveBody */ + body?: WhatsAppInteractiveBody; + /** @see WhatsAppInteractiveFooter */ + footer?: WhatsAppInteractiveFooter; + /** ID of the Flow. */ + flow_id: string; + /** Generated token which is an identifier. */ + flow_token?: string; + /** The mode in which the flow is. */ + flow_mode?: 'draft' | 'published'; + /** Text which is displayed on the Call To Action button (20 characters maximum, emoji not supported). */ + flow_cta: string; + /** */ + flow_action?: 'navigate' | 'data_exchange'; + /** @see FlowChannelSpecificMessageFlowActionPayload */ + flow_action_payload?: FlowChannelSpecificMessageFlowActionPayload; +} + +type FlowChannelSpecificMessageHeader = + WhatsAppInteractiveTextHeader + | WhatsAppInteractiveImageHeader + | WhatsAppInteractiveDocumentHeader + | WhatsAppInteractiveVideoHeader; + +interface FlowChannelSpecificMessageFlowActionPayload { + /** The ID of the screen displayed first. This must be an entry screen. */ + screen?: string; + /** Data for the first screen. */ + data?: object; +} diff --git a/packages/conversation/src/models/v1/flow-channel-specific-message/index.ts b/packages/conversation/src/models/v1/flow-channel-specific-message/index.ts new file mode 100644 index 00000000..1cd18868 --- /dev/null +++ b/packages/conversation/src/models/v1/flow-channel-specific-message/index.ts @@ -0,0 +1 @@ +export type { FlowChannelSpecificMessage } from './flow-channel-specific-message'; diff --git a/packages/conversation/src/models/v1/index.ts b/packages/conversation/src/models/v1/index.ts index df2b8256..aef1e6c6 100644 --- a/packages/conversation/src/models/v1/index.ts +++ b/packages/conversation/src/models/v1/index.ts @@ -15,6 +15,8 @@ export * from './channel-identity'; export * from './channel-template-override'; export * from './channel-template-reference'; export * from './channel-recipient-identity'; +export * from './channel-specific-contact-message'; +export * from './channel-specific-message'; export * from './choice'; export * from './choice-message'; export * from './choice-response-message'; @@ -43,6 +45,7 @@ export * from './create-conversation-request'; export * from './delivery-report-based-fallback'; export * from './dispatch-retention-policy'; export * from './fallback-message'; +export * from './flow-channel-specific-message'; export * from './generic-event'; export * from './get-channel-profile-request'; export * from './get-channel-profile-response'; @@ -61,6 +64,8 @@ export * from './media-message'; export * from './merge-contact-request'; export * from './message-retry-settings'; export * from './product'; +export * from './product-item'; +export * from './product-response-message'; export * from './error-detail'; export * from './lookup-capability-request'; export * from './lookup-capability-response'; @@ -94,6 +99,14 @@ export * from './v2-template-response'; export * from './v2-template-translation'; export * from './webhook'; export * from './webhook-trigger'; +export * from './whatsapp-interactive-body'; +export * from './whatsapp-interactive-document-header'; +export * from './whatsapp-interactive-footer'; +export * from './whatsapp-interactive-header-media'; +export * from './whatsapp-interactive-image-header'; +export * from './whatsapp-interactive-nfm-reply'; +export * from './whatsapp-interactive-text-header'; +export * from './whatsapp-interactive-video-header'; export * from './enums'; export * from './helper'; export * from './mod-callback-events'; diff --git a/packages/conversation/src/models/v1/list-section/list-section.ts b/packages/conversation/src/models/v1/list-section/list-section.ts index 0624f4e4..2c621dae 100644 --- a/packages/conversation/src/models/v1/list-section/list-section.ts +++ b/packages/conversation/src/models/v1/list-section/list-section.ts @@ -2,7 +2,7 @@ import { ChoiceItem } from '../choice-item'; import { Product } from '../product'; /** - * Section for interactive whatsapp messages containing ListItem + * Section for interactive WhatsApp messages containing ListItem */ export interface ListSection { diff --git a/packages/conversation/src/models/v1/message-retry-settings/message-retry-settings.ts b/packages/conversation/src/models/v1/message-retry-settings/message-retry-settings.ts index 6c763544..14c9d4be 100644 --- a/packages/conversation/src/models/v1/message-retry-settings/message-retry-settings.ts +++ b/packages/conversation/src/models/v1/message-retry-settings/message-retry-settings.ts @@ -7,7 +7,7 @@ export interface MessageRetrySettings { /** * The maximum duration, in seconds, for which to retry sending a message in case of a temporary processing failure. Time is counted after the first message processing failure. At least one retry is guaranteed. * Subsequent retry times are randomized with exponential backoff. If the next retry timestamp exceeds the configured time, one last retry will be performed on the cut-off time. - * If the message has a configured fallback channel, a switch_on_channel will be triggered. + * If the message has a configured fallback channel, a switch_on_channel will be triggered. * The valid values for this field are [30 - 3600]. Default value is 3600 (seconds - 1 hour). */ retry_duration?: number; diff --git a/packages/conversation/src/models/v1/product-item/index.ts b/packages/conversation/src/models/v1/product-item/index.ts new file mode 100644 index 00000000..050a45ee --- /dev/null +++ b/packages/conversation/src/models/v1/product-item/index.ts @@ -0,0 +1 @@ +export type { ProductItem } from './product-item'; diff --git a/packages/conversation/src/models/v1/product-item/product-item.ts b/packages/conversation/src/models/v1/product-item/product-item.ts new file mode 100644 index 00000000..8456c479 --- /dev/null +++ b/packages/conversation/src/models/v1/product-item/product-item.ts @@ -0,0 +1,15 @@ +/** + * A message component for interactive messages, containing a product. + */ +export interface ProductItem { + /** Required parameter. The ID for the product. */ + id: string; + /** Required parameter. The marketplace to which the product belongs. */ + marketplace: string; + /** Output only. The quantity of the chosen product. */ + quantity?: number; + /** Output only. The price for one unit of the chosen product. */ + item_price?: number; + /** Output only. The currency of the item_price. */ + currency?: string; +} diff --git a/packages/conversation/src/models/v1/product-response-message/index.ts b/packages/conversation/src/models/v1/product-response-message/index.ts new file mode 100644 index 00000000..f71be3da --- /dev/null +++ b/packages/conversation/src/models/v1/product-response-message/index.ts @@ -0,0 +1 @@ +export type { ProductResponseMessage } from './product-response-message'; diff --git a/packages/conversation/src/models/v1/product-response-message/product-response-message.ts b/packages/conversation/src/models/v1/product-response-message/product-response-message.ts new file mode 100644 index 00000000..bc974dd6 --- /dev/null +++ b/packages/conversation/src/models/v1/product-response-message/product-response-message.ts @@ -0,0 +1,13 @@ +import { ProductItem } from '../product-item'; + +/** + * Represents an interactive WhatsApp message containing ProductItem objects + */ +export interface ProductResponseMessage { + /** The selected products. */ + products: ProductItem[]; + /** Optional parameter. Text that may be sent with selected products. */ + text?: string; + /** Optional parameter. The catalog id that the selected products belong to. */ + catalog_id?: string; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-body/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-body/index.ts new file mode 100644 index 00000000..7182eed1 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-body/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveBody } from './whatsapp-interactive-body'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-body/whatsapp-interactive-body.ts b/packages/conversation/src/models/v1/whatsapp-interactive-body/whatsapp-interactive-body.ts new file mode 100644 index 00000000..68c7571e --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-body/whatsapp-interactive-body.ts @@ -0,0 +1,7 @@ +/** + * Body of the interactive message. + */ +export interface WhatsAppInteractiveBody { + /** The content of the message (1024 characters maximum). Emojis and Markdown are supported. */ + text: string; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-document-header/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-document-header/index.ts new file mode 100644 index 00000000..a2662403 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-document-header/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveDocumentHeader } from './whatsapp-interactive-document-header'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-document-header/whatsapp-interactive-document-header.ts b/packages/conversation/src/models/v1/whatsapp-interactive-document-header/whatsapp-interactive-document-header.ts new file mode 100644 index 00000000..be694b51 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-document-header/whatsapp-interactive-document-header.ts @@ -0,0 +1,11 @@ +import { WhatsAppInteractiveHeaderMedia } from '../whatsapp-interactive-header-media'; + +/** + * Header of the interactive message with document. + */ +export interface WhatsAppInteractiveDocumentHeader { + /** Must be set to document. */ + type: 'document'; + /** @see WhatsAppInteractiveHeaderMedia */ + document: WhatsAppInteractiveHeaderMedia; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-footer/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-footer/index.ts new file mode 100644 index 00000000..8b6bd6ed --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-footer/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveFooter } from './whatsapp-interactive-footer'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-footer/whatsapp-interactive-footer.ts b/packages/conversation/src/models/v1/whatsapp-interactive-footer/whatsapp-interactive-footer.ts new file mode 100644 index 00000000..e6335c39 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-footer/whatsapp-interactive-footer.ts @@ -0,0 +1,7 @@ +/** + * Footer of the interactive message. + */ +export interface WhatsAppInteractiveFooter { + /** The footer content (60 characters maximum). Emojis, Markdown and links are supported. */ + text: string; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-header-media/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-header-media/index.ts new file mode 100644 index 00000000..a6ca0ed8 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-header-media/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveHeaderMedia } from './whatsapp-interactive-header-media'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-header-media/whatsapp-interactive-header-media.ts b/packages/conversation/src/models/v1/whatsapp-interactive-header-media/whatsapp-interactive-header-media.ts new file mode 100644 index 00000000..3c2f03d7 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-header-media/whatsapp-interactive-header-media.ts @@ -0,0 +1,7 @@ +/** + * Media object for the header. + */ +export interface WhatsAppInteractiveHeaderMedia { + /** URL for the media. */ + link: string; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-image-header/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-image-header/index.ts new file mode 100644 index 00000000..47557ccf --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-image-header/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveImageHeader } from './whatsapp-interactive-image-header'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-image-header/whatsapp-interactive-image-header.ts b/packages/conversation/src/models/v1/whatsapp-interactive-image-header/whatsapp-interactive-image-header.ts new file mode 100644 index 00000000..3c44a65b --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-image-header/whatsapp-interactive-image-header.ts @@ -0,0 +1,11 @@ +import { WhatsAppInteractiveHeaderMedia } from '../whatsapp-interactive-header-media'; + +/** + * Header of the interactive message with image. + */ +export interface WhatsAppInteractiveImageHeader { + /** Must be set to image. */ + type: 'image'; + /** @see WhatsAppInteractiveHeaderMedia */ + image: WhatsAppInteractiveHeaderMedia; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/index.ts new file mode 100644 index 00000000..412777e8 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveNfmReply } from './whatsapp-interactive-nfm-reply'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/whatsapp-interactive-nfm-reply.ts b/packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/whatsapp-interactive-nfm-reply.ts new file mode 100644 index 00000000..2a1706c5 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-nfm-reply/whatsapp-interactive-nfm-reply.ts @@ -0,0 +1,11 @@ +/** + * The interactive nfm reply message. + */ +export interface WhatsAppInteractiveNfmReply { + /** The nfm reply message type. */ + name: 'flow' | 'address_message'; + /** The JSON specific data. */ + response_json: string; + /** The message body. */ + body: string; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-text-header/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-text-header/index.ts new file mode 100644 index 00000000..214fdeb9 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-text-header/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveTextHeader } from './whatsapp-interactive-text-header'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-text-header/whatsapp-interactive-text-header.ts b/packages/conversation/src/models/v1/whatsapp-interactive-text-header/whatsapp-interactive-text-header.ts new file mode 100644 index 00000000..ed931fde --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-text-header/whatsapp-interactive-text-header.ts @@ -0,0 +1,9 @@ +/** + * Header of the interactive message with text. + */ +export interface WhatsAppInteractiveTextHeader { + /** Must be set to text. */ + type: 'text'; + /** Text for the header. Formatting allows emojis, but not Markdown. */ + text: string; +} diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-video-header/index.ts b/packages/conversation/src/models/v1/whatsapp-interactive-video-header/index.ts new file mode 100644 index 00000000..08fa43d4 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-video-header/index.ts @@ -0,0 +1 @@ +export type { WhatsAppInteractiveVideoHeader } from './whatsapp-interactive-video-header'; diff --git a/packages/conversation/src/models/v1/whatsapp-interactive-video-header/whatsapp-interactive-video-header.ts b/packages/conversation/src/models/v1/whatsapp-interactive-video-header/whatsapp-interactive-video-header.ts new file mode 100644 index 00000000..0b67b821 --- /dev/null +++ b/packages/conversation/src/models/v1/whatsapp-interactive-video-header/whatsapp-interactive-video-header.ts @@ -0,0 +1,11 @@ +import { WhatsAppInteractiveHeaderMedia } from '../whatsapp-interactive-header-media'; + +/** + * Header of the interactive message with video. + */ +export interface WhatsAppInteractiveVideoHeader { + /** Must be set to video. */ + type: 'video'; + /** @see WhatsAppInteractiveHeaderMedia */ + video: WhatsAppInteractiveHeaderMedia; +} diff --git a/packages/conversation/src/rest/v1/contact/contact-api.ts b/packages/conversation/src/rest/v1/contact/contact-api.ts index 42ffb68a..e106068f 100644 --- a/packages/conversation/src/rest/v1/contact/contact-api.ts +++ b/packages/conversation/src/rest/v1/contact/contact-api.ts @@ -160,7 +160,9 @@ export class ContactApi extends ConversationDomainApi { /** * Get a Contact - * Returns a specific contact as specified by the contact ID. Note that, if a WhatsApp contact is returned, the `display_name` field of that contact may be populated with the WhatsApp display name (if the name is already stored on the server and the `display_name` field has not been overwritten by the user). + * Returns a specific contact as specified by the contact ID. Note the following: + * - If a WhatsApp contact is returned, the `display_name` field of that contact may be populated with the WhatsApp display name (if the name is already stored on the server and the `display_name` field has not been overwritten by the user). + * - If you receive an Inbound Message callback for an MO message on the Instagram channel, the corresponding payload will not include the Instagram username. You may use the `contact_id` and `channel_identity` values included in the callback to retrieve the username (detailed in the `display_name` field) with this Conversation API operation. * @param { GetContactRequestData } data - The data to provide to the API call. */ public async get(data: GetContactRequestData): Promise { diff --git a/packages/conversation/src/rest/v1/conversation/conversation-api.ts b/packages/conversation/src/rest/v1/conversation/conversation-api.ts index 6988754f..7a596ee0 100644 --- a/packages/conversation/src/rest/v1/conversation/conversation-api.ts +++ b/packages/conversation/src/rest/v1/conversation/conversation-api.ts @@ -38,7 +38,7 @@ export interface InjectEventRequestData { 'injectConversationEventRequestBody': InjectConversationEventRequest; } export interface InjectMessageRequestData { - /** Required. The ID of the conversation. */ + /** The ID of the conversation. */ 'conversation_id': string; /** Message to be injected. */ 'injectMessageRequestBody': InjectMessageRequest; @@ -46,9 +46,9 @@ export interface InjectMessageRequestData { export interface ListConversationsRequestData { /** Required. True if only active conversations should be listed. */ 'only_active': boolean; - /** The ID of the app involved in the conversations. */ + /** The ID of the app involved in the conversations. Note that either `app_id` or `contact_id` is required in order for the operation to function correctly. */ 'app_id'?: string; - /** Resource name (ID) of the contact. */ + /** Resource name (ID) of the contact. Note that either `app_id` or `contact_id` is required in order for the operation to function correctly. */ 'contact_id'?: string; /** The maximum number of conversations to fetch. Defaults to 10 and the maximum is 20. */ 'page_size'?: number; @@ -64,7 +64,8 @@ export interface ListRecentConversationsRequestData { 'only_active'?: boolean; /** The maximum number of conversations to fetch. Defaults to 10 and the maximum value is 50. */ 'page_size'?: number; - /** Next page token previously returned if any. When specifying this token, make sure to use the same values for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ + /** Next page token previously returned if any. When specifying this token, make sure to use the same values + * for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ 'page_token'?: string; /** Whether to sort conversations by newest message first or oldest. Default is DESC (newest first) */ 'order'?: 'ASC' | 'DESC'; @@ -208,7 +209,7 @@ export class ConversationApi extends ConversationDomainApi { } /** - * Inject messages + * Inject a message * This operation injects a conversation message in to a specific conversation. * @param { InjectMessageRequestData } data - The data to provide to the API call. */ diff --git a/packages/conversation/src/rest/v1/events/events-api.ts b/packages/conversation/src/rest/v1/events/events-api.ts index 63f3a716..969d55e0 100644 --- a/packages/conversation/src/rest/v1/events/events-api.ts +++ b/packages/conversation/src/rest/v1/events/events-api.ts @@ -37,7 +37,8 @@ export interface ListEventsRequestData { 'contact_id'?: string; /** Maximum number of events to fetch. Defaults to 10 and the maximum is 20. */ 'page_size'?: number; - /** Next page token previously returned if any. When specifying this token, make sure to use the same values for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ + /** Next page token previously returned if any. When specifying this token, make sure to use the same values + * for the other parameters from the request that originated the token, otherwise the paged results may be inconsistent. */ 'page_token'?: string; } export interface SendEventRequestData {