zendesk-messaging-client
Version:
Zendesk messaging API client
1,476 lines • 221 kB
TypeScript
export type Page = {
/**
* A record id. Results will only contain the records that come after the specified record.
* Only one of `after` or `before` can be provided, not both.
*
*/
after?: string;
/**
* A record id. Results will only contain the records that come before the specified record.
* Only one of `after` or `before` can be provided, not both.
*
*/
before?: string;
/**
* The number of records to return. Does not apply to the `listMessages` endpoint.
*/
size?: number;
};
export type DisplayName = string | null;
/**
* Customizable app settings.
*/
export type AppSettings = {
/**
* Number of seconds of inactivity before a conversation’s messages
* will be automatically deleted. See
* [Conversation Retention Seconds](https://docs.smooch.io/guide/creating-and-managing-apps/#conversation-retention-seconds)
* for more information.
*
*/
conversationRetentionSeconds?: number;
/**
* A boolean specifying whether credit card numbers should be masked
* when sent through Sunshine Conversations.
*
*/
maskCreditCardNumbers?: boolean;
/**
* A boolean specifying whether animal names should be used for
* unnamed users. See the
* [user naming guide](https://docs.smooch.io/guide/receiving-messages/#message-author-name)
* for details.
*
*/
useAnimalNames?: boolean;
/**
* A boolean specifying whether a message should be added to the conversation
* history when a postback button is clicked. See
* [Echo Postbacks](https://docs.smooch.io/guide/creating-and-managing-apps/#echo-postbacks)
* for more information.
*
*/
echoPostback?: boolean;
/**
* A boolean specifying whether a non message event coming from a channel will
* trigger a
* [start conversation](https://docs.smooch.io/rest/#section/Webhook-Triggers)
* event and count as a monthly active user (MAU).
* <aside class="notice">Calling <code>startConversation()</code> (or equivalent) from the Android,
* iOS or Web SDK will count as a MAU, regardless of the value of this setting.</aside>
*
*/
ignoreAutoConversationStart?: boolean;
/**
* A boolean specifying whether users are allowed to be part of several conversations.
* Enabling `multiConvo` is **irreversible**.
*
*/
multiConvoEnabled?: boolean;
/**
* A boolean specifying whether the messages authored by the Sunshine Conversations platform should be localized.
*
*/
appLocalizationEnabled?: boolean;
};
/**
* Flat object containing custom properties. Strings, numbers and booleans
* are the only supported format that can be passed to metadata.
* The metadata is limited to 4KB in size.
*
*/
export type Metadata = {
[key: string]: unknown;
} | null;
export type App = {
/**
* A canonical ID that can be used to retrieve the Sunshine Conversations app.
*/
id?: string;
/**
* The friendly name of the app.
*/
displayName?: DisplayName;
settings?: AppSettings;
metadata?: Metadata;
};
/**
* Response metadata.
*/
export type Meta = {
/**
* A flag that indicates if there are more records that can be fetched.
*/
hasMore?: boolean;
/**
* A record id that can be used as a `page[after]` parameter in a new request to get the next page.
* Not specified if there are no subsequent pages.
*
*/
afterCursor?: string;
/**
* A record id that can be used as a `page[before]` parameter in a new request to get the previous page.
* Not specified if there are no previous pages.
*
*/
beforeCursor?: string;
};
/**
* Previous and next page links, if they exist.
*/
export type Links = {
/**
* A link to the previous page. Not specified if there are no previous pages.
*/
prev?: string;
/**
* A link to the next page. Not specified if there are no subsequent pages.
*/
next?: string;
};
export type AppListResponse = {
/**
* List of returned apps.
*/
apps?: Array<App>;
meta?: Meta;
links?: Links;
};
export type _Error = {
/**
* Error code used for classifying similar error types
*/
code?: string;
/**
* Description of the error
*/
title?: string;
};
export type ErrorResponse = {
/**
* List of errors that occurred.
*/
errors?: Array<_Error>;
};
/**
* AppCreateBody
*/
export type AppCreateBody = {
/**
* The friendly name of the app.
*/
displayName: DisplayName;
settings?: AppSettings;
metadata?: Metadata;
};
/**
* AppResponse
*/
export type AppResponse = {
/**
* The app.
*/
app?: App;
};
export type AppUpdateBody = {
/**
* The friendly name of the app.
*/
displayName?: DisplayName;
settings?: AppSettings;
metadata?: Metadata;
};
export type AppKey = {
/**
* The unique ID of the API key, used when signing JWTs or accessing the API using Basic Authentication.
*/
id?: string;
/**
* The name of the API key.
*/
displayName?: string;
/**
* The secret of the API key, used when signing JWTs or accessing the API using Basic Authentication
*/
secret?: string;
};
export type AppKeyListResponse = {
/**
* List of returned keys.
*/
keys?: Array<AppKey>;
};
/**
* AppKeyResponse
*/
export type AppKeyResponse = {
/**
* The created key object.
*/
key?: AppKey;
};
export type AttachmentUploadBody = {
source: Blob | File;
};
export type AttachmentSchema = {
/**
* Uploaded attachment’s url.
* <aside class="notice">Note that for private attachments an authorization header is required to access the mediaUrl. See [configuring private attachments for messaging](https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/messaging_private_attachments/) guide for more details.</aside>
*
*/
mediaUrl?: string;
/**
* Uploaded attachment's media type
*/
mediaType?: string;
};
/**
* AttachmentResponse
*/
export type AttachmentResponse = {
/**
* The uploaded attachment object.
*/
attachment?: AttachmentSchema;
};
export type AttachmentDeleteBody = {
/**
* The media URL used for a file or image message.
*/
mediaUrl: string;
};
/**
* The type of the conversation.
*/
export type ConversationType = 'personal' | 'sdkGroup';
/**
* Identifier for use in control transfer protocols. Restricted to alphanumeric characters, `-` and `_`.
*/
export type Name = string;
/**
* Id of the integration that should deliver events routed by the switchboard.
*/
export type SwitchboardIntegrationId = string;
/**
* Type of integration that should deliver events routed by the switchboard. If referencing an OAuth integration, the clientId issued by Sunshine Conversations during the OAuth partnership process will be the value of integrationType.
*/
export type SwitchboardIntegrationType = string;
export type SwitchboardIntegrationWebhook = {
/**
* The unique ID of the switchboard integration.
*/
id?: string;
name?: Name;
integrationId?: SwitchboardIntegrationId;
integrationType?: SwitchboardIntegrationType;
};
export type ConversationTruncated = {
/**
* The unique ID of the conversation.
*/
id?: string;
type?: ConversationType;
metadata?: Metadata;
/**
* The current switchboard integration that is in control of the conversation. This field is omitted if no `activeSwitchboardIntegration` exists for the conversation.
*/
activeSwitchboardIntegration?: SwitchboardIntegrationWebhook | null;
/**
* The switchboard integration that is awaiting control. This field is omitted if no switchboard integration has been previously offered control.
*/
pendingSwitchboardIntegration?: SwitchboardIntegrationWebhook | null;
};
/**
* A short text describing the conversation.
*/
export type Description = string | null;
/**
* A custom conversation icon url. The image must be in either JPG, PNG, or GIF format
*/
export type Icon = string | null;
export type Conversation = ConversationTruncated & {
/**
* Whether the conversation is the default conversation for the user. Will be
* true for the first personal conversation created for the user, and false in
* all other cases.
*
*/
isDefault?: boolean;
/**
* A friendly name for the conversation, may be displayed to the business or
* the user.
*
*/
displayName?: DisplayName;
description?: Description;
iconUrl?: Icon;
/**
* A datetime string with the format YYYY-MM-DDThh:mm:ss.SSSZ
* representing the moment the conversation was last marked as read with
* role business.
*
*/
businessLastRead?: string | null;
/**
* A datetime string with the format YYYY-MM-DDThh:mm:ss.SSSZ
* representing the moment the last message was received in the
* conversation, or the creation time if no messages have been received yet.
*
*/
lastUpdatedAt?: string | null;
/**
* A datetime string with the format YYYY-MM-DDThh:mm:ss.SSSZ
* representing the creation time of the conversation.
*
*/
createdAt?: string;
};
export type ConversationListResponse = {
/**
* List of returned conversations.
*/
conversations?: Array<Conversation>;
meta?: Meta;
links?: Links;
};
export type ParticipantSubSchema = {
/**
* The id of the user that will be participating in the conversation. It will return `404` if the user can’t be found. One of `userId` or `userExternalId` is required, but not both.
*/
userId?: string;
/**
* When passed as true, the SDK client of the concerned participant will be subscribed to the conversation. The user will start receiving push notifications for this conversation right away, without having to view the conversation on the SDK beforehand. An SDK client will be created for users that don’t already have one. This field is required if the conversation is of type `sdkGroup`.
*/
subscribeSDKClient?: boolean;
} | {
/**
* The `externalId` of the user that will be participating in the conversation. It will return `404` if the user can’t be found. One of `userId` or `userExternalId` is required, but not both.
*/
userExternalId?: string;
/**
* When passed as true, the SDK client of the concerned participant will be subscribed to the conversation. The user will start receiving push notifications for this conversation right away, without having to view the conversation on the SDK beforehand. An SDK client will be created for users that don’t already have one. This field is required if the conversation is of type `sdkGroup`.
*/
subscribeSDKClient?: boolean;
};
/**
* ConversationCreateBody
*/
export type ConversationCreateBody = {
type: ConversationType;
/**
* The users participating in the conversation. For `personal` conversations, this field is required with a length of exactly 1. For `sdkGroup` conversations, must have a length less than or equal to 10.
* Can be omitted to have a conversation with no participants if the type is `sdkGroup`.
*
*/
participants?: Array<ParticipantSubSchema>;
/**
* A friendly name for the conversation, may be displayed to the business or
* the user.
*
*/
displayName?: DisplayName;
description?: Description;
iconUrl?: Icon;
metadata?: Metadata;
};
/**
* ConversationResponse
*/
export type ConversationResponse = {
/**
* The conversation.
*/
conversation?: Conversation;
};
export type ConversationUpdateBody = {
/**
* A friendly name for the conversation, may be displayed to the business or
* the user.
*
*/
displayName?: DisplayName;
description?: Description;
iconUrl?: Icon;
metadata?: Metadata;
};
export type ParticipantJoinBody = ParticipantSubSchema;
/**
* The type of integration that the client represents. Can be any of the supported integration types, or sdk for integrations of type ios, android, unity and web.
*/
export type ClientType = 'apple' | 'gbm' | 'googlercs' | 'instagram' | 'kakao' | 'line' | 'mailgun' | 'messagebird' | 'messenger' | 'slackconnect' | 'sdk' | 'telegram' | 'twilio' | 'twitter' | 'viber' | 'wechat' | 'whatsapp';
export type ClientAssociation = {
type?: ClientType;
/**
* The id of the client being referenced.
*/
clientId?: string;
};
export type Participant = {
/**
* The unique ID of the participant.
*/
id?: string;
/**
* The id of the associated user.
*/
userId?: string;
/**
* Number of messages the user has not yet read.
*/
unreadCount?: number;
/**
* Represents the clients that are active in the conversation for a particular
* user. A participant can have multiple clientAssociations in the case of
* channel transfer, business initiated conversations, or identified users.
* The order of the array indicates how recently a client has interacted with
* the conversation, with the most recent client first. The first item in the
* array is considered to be the user's primary client for that conversation,
* and will be selected first for message delivery.
*
*/
clientAssociations?: Array<ClientAssociation>;
/**
* The externalId of the associated user.
*/
userExternalId?: string | null;
/**
* A datetime string with the format YYYY-MM-DDThh:mm:ss.SSSZ representing the latest message the user has read.
*/
lastRead?: string | null;
};
/**
* List of returned participants.
*/
export type ParticipantListResponse = {
participants?: Array<Participant>;
meta?: Meta;
links?: Links;
};
export type ParticipantLeaveBody = {
/**
* The id of the user that will be removed from the conversation. It will
* return 404 if the user can’t be found.
*
*/
userId?: string;
} | {
/**
* The externalId of the user that will be removed from the conversation. It
* will return 404 if the user can’t be found.
*
*/
userExternalId?: string;
} | {
/**
* The participantId of the user that will be removed from the conversation.
* It will return 404 if the user can’t be found.
*
*/
participantId?: string;
};
/**
* The author of the message.
*/
export type AuthorReadable = {
/**
* The author type. Either "user" (representing the end user)
* or "business" (sent on behalf of the business).
*
*/
type: 'business' | 'user';
/**
* A string array that indicates the author's subtypes. Messages from "business" type with an "AI" subtype
* are generated by AI and a disclaimer is appended to the text of the message sent to the customer.
* For third-party channels, the disclaimer is applied for image, file, and text message types.
* Message with an "activity" subtype are generated by system activities.
*
*/
subtypes?: Array<'AI' | 'activity'>;
/**
* The id of the user. Only supported when `type` is user.
*/
userId?: string;
/**
* The display name of the message author.
*/
displayName?: string;
/**
* A custom message icon URL. The image must be JPG, PNG, or GIF format.
*/
avatarUrl?: Icon;
};
/**
* The author of the message.
*/
export type AuthorWritable = {
/**
* The author type. Either "user" (representing the end user)
* or "business" (sent on behalf of the business).
*
*/
type: 'business' | 'user';
/**
* A string array that indicates the author's subtypes. Messages from "business" type with an "AI" subtype
* are generated by AI and a disclaimer is appended to the text of the message sent to the customer.
* For third-party channels, the disclaimer is applied for image, file, and text message types.
* Message with an "activity" subtype are generated by system activities.
*
*/
subtypes?: Array<'AI' | 'activity'>;
/**
* The id of the user. Only supported when `type` is user.
*/
userId?: string;
/**
* The externalId of the user. Only supported when `type` is user.
*/
userExternalId?: string;
/**
* The display name of the message author.
*/
displayName?: string;
/**
* A custom message icon URL. The image must be JPG, PNG, or GIF format.
*/
avatarUrl?: Icon;
};
export type TicketClosedReadable = {
/**
* The type of system activity that generated the message. The value of this field determines the dynamic content that is rendered to the end-user / agent when viewing this message. Each `type` value will have a set of pre-defined, localized strings that describe the activity.
*/
type: string;
/**
* No additional data is supplied with the "ticket:closed" activity type at this time.
*/
data?: {
[key: string]: unknown;
};
};
export type TicketClosedWritable = {
/**
* The type of system activity that generated the message. The value of this field determines the dynamic content that is rendered to the end-user / agent when viewing this message. Each `type` value will have a set of pre-defined, localized strings that describe the activity.
*/
type: string;
/**
* No additional data is supplied with the "ticket:closed" activity type at this time.
*/
data?: {
[key: string]: unknown;
};
};
export type TransferToEmailReadable = {
/**
* The type of system activity that generated the message. The value of this field determines the dynamic content that is rendered to the end-user / agent when viewing this message. Each `type` value will have a set of pre-defined, localized strings that describe the activity.
*/
type: string;
/**
* No additional data is supplied with the "ticket:transfer:email" activity type at this time.
*/
data?: {
[key: string]: unknown;
};
};
export type TransferToEmailWritable = {
/**
* The type of system activity that generated the message. The value of this field determines the dynamic content that is rendered to the end-user / agent when viewing this message. Each `type` value will have a set of pre-defined, localized strings that describe the activity.
*/
type: string;
/**
* No additional data is supplied with the "ticket:transfer:email" activity type at this time.
*/
data?: {
[key: string]: unknown;
};
};
export type ActivityMessageReadable = ({
type: 'ticket:closed';
} & TicketClosedReadable) | ({
type: 'ticket:transfer:email';
} & TransferToEmailReadable);
export type ActivityMessageWritable = ({
type: 'ticket:closed';
} & TicketClosedWritable) | ({
type: 'ticket:transfer:email';
} & TransferToEmailWritable);
/**
* HTML text content of the message. Can be provided in place of `text`. Cannot be used with `markdownText`.
* If no `text` is provided, will be converted to `text` upon reception to be displayed on channels that do not support rich text.
* See [rich text](https://docs.smooch.io/guide/structured-messages/rich-text) documentation for more information.
*/
export type HtmlText = string;
/**
* Markdown text content of the message. Can be provided in place of `text`. Cannot be used with `htmlText`.
* Will be converted to `htmlText` upon reception. If converted `htmlText` exceeds 4096 characters, the message will be rejected.
* If no `text` is provided, will be converted to `text` upon reception to be displayed on channels that do not support rich text.
* See [rich text](https://docs.smooch.io/guide/structured-messages/rich-text) documentation for more information.
*/
export type MarkdownText = string;
export type Buy = {
/**
* The type of action.
*/
type: string;
/**
* The button text.
*/
text: string;
/**
* The amount being charged. It needs to be specified in cents and is an integer (9.99$ -> 999).
*/
amount: number;
/**
* An ISO 4217 standard currency code in lowercase. Used for actions of type buy.
*/
currency?: string;
metadata?: Metadata;
};
/**
* Extra options to pass directly to the channel API.
*/
export type ExtraChannelOptions = {
/**
* Messenger channel options.
*/
messenger?: {
/**
* For webview type actions, a boolean value indicating whether the URL should be loaded with Messenger Extensions enabled. [More info](https://developers.facebook.com/docs/messenger-platform/send-api-reference/url-button).
*/
messenger_extensions?: boolean;
/**
* For webview type actions, a string value indicating if the share button should be hidden. [More Info](https://developers.facebook.com/docs/messenger-platform/reference/buttons/url).
*/
webview_share_button?: 'hide';
};
};
/**
* A link action will open the provided URI when tapped.
*/
export type Link = {
/**
* The type of action.
*/
type: string;
/**
* The action URI. This is the link that will be used in the clients when clicking the button.
*/
uri: string;
/**
* The button text.
*/
text: string;
/**
* Boolean value indicating whether the action is the default action for a message item in Facebook Messenger.
*/
default?: boolean;
metadata?: Metadata;
extraChannelOptions?: ExtraChannelOptions;
};
/**
* A location request action will prompt the user to share their location.
*/
export type LocationRequest = {
/**
* The type of action.
*/
type: string;
/**
* The button text.
*/
text: string;
metadata?: Metadata;
};
export type Postback = {
/**
* The type of action.
*/
type: string;
/**
* The button text.
*/
text: string;
/**
* The payload of a postback or reply button.
*/
payload: string;
metadata?: Metadata;
};
export type Reply = {
/**
* The type of action.
*/
type: string;
/**
* The button text. We recommend a non-empty value because some channels may not support empty ones. Text longer than 20 characters will be truncated on Facebook Messenger, and longer than 40 characters will be truncated on Web Messenger, iOS, and Android.
*/
text: string;
/**
* A string payload to help you identify the action context. Used when posting the reply. You can also use metadata for more complex needs.
*/
payload: string;
metadata?: Metadata;
/**
* An icon to render next to the reply option.
*/
iconUrl?: string;
};
/**
* When a webview actions is clicked/tapped, the provided URI will be loaded in a webview. Channels that do not support webviews will open the fallback URI instead.
*/
export type Webview = {
/**
* The type of action.
*/
type: string;
/**
* The webview URI. This is the URI that will open in the webview when clicking the button.
*/
uri: string;
/**
* The button text.
*/
text: string;
/**
* Boolean value indicating whether the action is the default action for a message item in Facebook Messenger.
*/
default?: boolean;
metadata?: Metadata;
extraChannelOptions?: ExtraChannelOptions;
/**
* The size to display a webview. Used for actions of type webview.
*/
size?: 'compact' | 'tall' | 'full';
/**
* The fallback uri for channels that don’t support webviews. Used for actions of type webview.
*/
fallback: string;
/**
* Boolean value indicating if the webview should open automatically. Only one action per message can be set to true. Currently only supported on the Web Messenger.
*/
openOnReceive?: boolean;
};
export type Action = ({
type: 'buy';
} & Buy) | ({
type: 'link';
} & Link) | ({
type: 'locationRequest';
} & LocationRequest) | ({
type: 'postback';
} & Postback) | ({
type: 'reply';
} & Reply) | ({
type: 'webview';
} & Webview);
export type TextMessageReadable = {
/**
* The type of message.
*/
type: string;
/**
* The text content of the message. Required unless `actions`, `htmlText` or `markdownText` is provided.
*/
text?: string;
htmlText?: HtmlText;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
/**
* Array of message actions.
*/
actions?: Array<Action>;
/**
* The payload of a [reply button](https://docs.smooch.io/guide/structured-messages/#reply-buttons) response message.
*/
payload?: string;
};
export type TextMessageWritable = {
/**
* The type of message.
*/
type: string;
/**
* The text content of the message. Required unless `actions`, `htmlText` or `markdownText` is provided.
*/
text?: string;
htmlText?: HtmlText;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
markdownText?: MarkdownText;
/**
* Array of message actions.
*/
actions?: Array<Action>;
/**
* The payload of a [reply button](https://docs.smooch.io/guide/structured-messages/#reply-buttons) response message.
*/
payload?: string;
};
export type ActionSubset = ({
type: 'buy';
} & Buy) | ({
type: 'link';
} & Link) | ({
type: 'postback';
} & Postback) | ({
type: 'webview';
} & Webview);
export type Item = {
/**
* The title of the item.
*/
title: string;
/**
* The description of the item.
*/
description?: string;
/**
* The image url attached to the item.
*/
mediaUrl?: string;
/**
* The MIME type for any image attached in the mediaUrl.
*/
mediaType?: string;
/**
* An optional description of the media for accessibility purposes. The field will be saved by default with the file name as the value.
*/
altText?: string;
/**
* The size of the image.
*/
size?: 'compact' | 'large';
/**
* An array of objects representing the actions associated with the item.
*/
actions: Array<ActionSubset>;
metadata?: Metadata;
};
/**
* Carousel messages are a horizontally scrollable set of items that may each contain text, an image, and message actions. Not all messaging channels fully support carousel messages; currently only Facebook Messenger, LINE, Telegram, Viber, the Web Messenger, the Android SDK and the iOS SDK cover the full functionality. For all other platforms a carousel message is rendered as raw text. The raw text fallback does not include any images or postback message actions.
*/
export type CarouselMessageReadable = {
/**
* The type of message.
*/
type: string;
/**
* The fallback text message used when carousel messages are not supported by the channel.
*/
readonly text?: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
/**
* An array of objects representing the items associated with the message. Only present in carousel and list type messages.
*/
items: Array<Item>;
/**
* Settings to adjust the carousel layout.
*/
displaySettings?: {
/**
* Specifies how to display all carousel images. Valid values are horizontal (default) and square. Only supported in Facebook Messenger, Web Messenger, Android SDK and iOS SDK carousels.
*/
imageAspectRatio?: 'horizontal' | 'square';
};
};
/**
* Carousel messages are a horizontally scrollable set of items that may each contain text, an image, and message actions. Not all messaging channels fully support carousel messages; currently only Facebook Messenger, LINE, Telegram, Viber, the Web Messenger, the Android SDK and the iOS SDK cover the full functionality. For all other platforms a carousel message is rendered as raw text. The raw text fallback does not include any images or postback message actions.
*/
export type CarouselMessageWritable = {
/**
* The type of message.
*/
type: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
/**
* An array of objects representing the items associated with the message. Only present in carousel and list type messages.
*/
items: Array<Item>;
/**
* Settings to adjust the carousel layout.
*/
displaySettings?: {
/**
* Specifies how to display all carousel images. Valid values are horizontal (default) and square. Only supported in Facebook Messenger, Web Messenger, Android SDK and iOS SDK carousels.
*/
imageAspectRatio?: 'horizontal' | 'square';
};
};
export type FileMessageReadable = {
/**
* The type of message.
*/
type: string;
/**
* The URL for media, such as an image, attached to the message.
* <aside class="notice">Note that for private attachments an authorization header is required to access the mediaUrl. See [configuring private attachments for messaging](https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/messaging_private_attachments/) guide for more details.</aside>
*
*/
mediaUrl: string;
/**
* The size of the media.
*/
readonly mediaSize?: number;
/**
* The media type of the file.
*/
readonly mediaType?: string;
/**
* An optional description of the file for accessibility purposes. The field will be saved by default with the file name as the value.
*/
altText?: string;
/**
* The text content of the message.
*/
text?: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
htmlText?: HtmlText;
/**
* An identifier used by Sunshine Conversations for internal purposes.
*/
attachmentId?: string;
};
export type FileMessageWritable = {
/**
* The type of message.
*/
type: string;
/**
* The URL for media, such as an image, attached to the message.
* <aside class="notice">Note that for private attachments an authorization header is required to access the mediaUrl. See [configuring private attachments for messaging](https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/messaging_private_attachments/) guide for more details.</aside>
*
*/
mediaUrl: string;
/**
* An optional description of the file for accessibility purposes. The field will be saved by default with the file name as the value.
*/
altText?: string;
/**
* The text content of the message.
*/
text?: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
htmlText?: HtmlText;
markdownText?: MarkdownText;
/**
* An identifier used by Sunshine Conversations for internal purposes.
*/
attachmentId?: string;
};
export type Field = {
/**
* The field type.
*/
type: 'email' | 'select' | 'text';
/**
* The name of the field. Must be unique per form or formResponse.
*/
name: string;
/**
* The label of the field. What the field is displayed as on Web Messenger.
*/
label: string;
/**
* Specifies the response for a text field.
*/
text?: string;
/**
* Specifies the response for a email field.
*/
email?: string;
/**
* Array of objects representing the response for a field of type select. Form and formResponse messages only.
*/
select?: Array<{
[key: string]: unknown;
}>;
};
/**
* Array of objects representing options for a field of type select.
*/
export type FormOptions = Array<{
/**
* The label of the option. What the option is displayed as on Web Messenger.
*/
label?: string;
/**
* The name of the field. Must be unique per field.
*/
name?: string;
}>;
export type FormMessageField = Field & {
/**
* Placeholder text for the field. Form message only.
*/
placeholder?: string;
/**
* The minimum allowed length for the response for a field of type text. Form message only.
*/
minSize?: number;
/**
* The maximum allowed length for the response for a field of type text. Form message only.
*/
maxSize?: number;
options?: FormOptions;
};
/**
* A form type message without text or actions. Only supported in the Web SDK.
*/
export type FormMessageReadable = {
/**
* The type of message.
*/
type: string;
/**
* Flag which states whether the form is submitted.
*/
readonly submitted?: boolean;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation..
*/
blockChatInput?: boolean;
/**
* An array of objects representing fields associated with the message. Only present in form and formResponse messages.
*/
fields: Array<FormMessageField>;
};
/**
* A form type message without text or actions. Only supported in the Web SDK.
*/
export type FormMessageWritable = {
/**
* The type of message.
*/
type: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation..
*/
blockChatInput?: boolean;
/**
* An array of objects representing fields associated with the message. Only present in form and formResponse messages.
*/
fields: Array<FormMessageField>;
};
export type FormResponseMessageFieldReadable = Field;
export type FormResponseMessageFieldWritable = Field & {
/**
* The messageId for the form that this response belongs to.
*/
quotedMessageId?: string;
};
/**
* A formResponse type message is a response to a form type message. formResponse type messages are only supported as responses to form messages on Web Messenger and cannot be sent via the API.
*/
export type FormResponseMessageReadable = {
/**
* The type of message.
*/
type: string;
/**
* Array of field objects that contain the submitted fields.
*/
fields: Array<FormResponseMessageFieldReadable>;
/**
* A string containing the `label: value` of all fields, each separated by a newline character.
*/
readonly textFallback?: string;
};
/**
* A formResponse type message is a response to a form type message. formResponse type messages are only supported as responses to form messages on Web Messenger and cannot be sent via the API.
*/
export type FormResponseMessageWritable = {
/**
* The type of message.
*/
type: string;
/**
* Array of field objects that contain the submitted fields.
*/
fields: Array<FormResponseMessageFieldWritable>;
};
export type ImageMessageReadable = {
/**
* The type of message.
*/
type: string;
/**
* The URL for media, such as an image, attached to the message.
* <aside class="notice">Note that for private attachments an authorization header is required to access the mediaUrl. See [configuring private attachments for messaging](https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/messaging_private_attachments/) guide for more details.</aside>
*
*/
mediaUrl: string;
/**
* The type of media.
*/
readonly mediaType?: string;
/**
* The size of the media in bytes.
*/
readonly mediaSize?: number;
/**
* An optional description of the image for accessibility purposes. The field will be saved by default with the file name as the value.
*/
altText?: string;
/**
* The text content of the message.
*/
text?: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
htmlText?: HtmlText;
/**
* Array of message actions.
*/
actions?: Array<Action>;
/**
* An identifier used by Sunshine Conversations for internal purposes.
*/
attachmentId?: string;
};
export type ImageMessageWritable = {
/**
* The type of message.
*/
type: string;
/**
* The URL for media, such as an image, attached to the message.
* <aside class="notice">Note that for private attachments an authorization header is required to access the mediaUrl. See [configuring private attachments for messaging](https://developer.zendesk.com/documentation/zendesk-web-widget-sdks/messaging_private_attachments/) guide for more details.</aside>
*
*/
mediaUrl: string;
/**
* An optional description of the image for accessibility purposes. The field will be saved by default with the file name as the value.
*/
altText?: string;
/**
* The text content of the message.
*/
text?: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
htmlText?: HtmlText;
markdownText?: MarkdownText;
/**
* Array of message actions.
*/
actions?: Array<Action>;
/**
* An identifier used by Sunshine Conversations for internal purposes.
*/
attachmentId?: string;
};
/**
* ListMessage
* List messages are a vertically scrollable set of items that may each contain text, an image, and message actions. Not all messaging channels fully support list messages.
* * Facebook Messenger and WeChat have native support.
* * For LINE and our Android, iOS and Web SDK, Sunshine Conversations converts list messages to carousel.
* * On WhatsApp, Telegram and Twitter, Sunshine Conversations converts list messages to multiple rich messages.
* * On all other platforms, Sunshine Conversations converts list messages to raw text.
*
*/
export type ListMessage = {
/**
* The type of message.
*/
type: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
/**
* An array of objects representing the items associated with the message. Only present in carousel and list type messages.
*/
items: Array<Item>;
/**
* An array of objects representing the actions associated with the message. The array length is limited by the third party channel.
*/
actions?: Array<ActionSubset>;
};
/**
* A location type message includes the coordinates (latitude and longitude) of a location and an optional location object which can include the name and address of the location. Typically sent in response to a Location Request.
*/
export type LocationMessageReadable = {
/**
* The type of message.
*/
type: string;
/**
* The fallback text message used when location messages are not supported by the channel.
*/
readonly text?: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
/**
* The coordinates of the location.
*/
coordinates: {
/**
* Global latitude.
*/
lat: number;
/**
* Global longitude.
*/
long: number;
};
/**
* Information about the location.
*/
location?: {
/**
* A string representing the address of the location.
*/
address?: string;
/**
* A string representing the name of the location.
*/
name?: string;
};
};
/**
* A location type message includes the coordinates (latitude and longitude) of a location and an optional location object which can include the name and address of the location. Typically sent in response to a Location Request.
*/
export type LocationMessageWritable = {
/**
* The type of message.
*/
type: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
/**
* The coordinates of the location.
*/
coordinates: {
/**
* Global latitude.
*/
lat: number;
/**
* Global longitude.
*/
long: number;
};
/**
* Information about the location.
*/
location?: {
/**
* A string representing the address of the location.
*/
address?: string;
/**
* A string representing the name of the location.
*/
name?: string;
};
};
export type TemplateMessage = {
/**
* The type of message.
*/
type: string;
/**
* When set to true, the chat input will be disabled on supported client implementations when the message is the most recent one in the history. Can be used for guided flows or to temporarily disable the user's ability to send messages in the conversation.
*/
blockChatInput?: boolean;
/**
* The whatsapp template message to send. For more information, consult the [guide](https://docs.smooch.io/guide/whatsapp#sending-message-templates). `schema` must be set to `whatsapp`.
*/
template: {
[key: string]: unknown;
};
};
export type ContentReadable = ({
type: 'text';
} & TextMessageReadable) | ({
type: 'carousel';
} & CarouselMessageReadable) | ({
type: 'file';
} & FileMessageReadable) | ({
type: 'form';
} & FormMessageReadable) | ({
type: 'formResponse';
} & FormResponseMessageReadable) | ({
type: 'image';
} & ImageMessageReadable) | ({
type: 'list';
} & ListMessage) | ({
type: 'location';
} & LocationMessageReadable) | ({
type: 'template';
} & TemplateMessage);
export type ContentWritable = ({
type: 'text';
} & TextMessageWritable) | ({
type: 'carousel';
} & CarouselMessageWritable) | ({
type: 'file';
} & FileMessageWritable) | ({
type: 'form';
} & FormMessageWritable) | ({
type: 'formResponse';
} & FormResponseMessageWritable) | ({
type: 'image';
} & ImageMessageWritable) | ({
type: 'list';
} & ListMessage) | ({
type: 'location';
} & LocationMessageWritable) | ({
type: 'template';
} & TemplateMessage);
export type Client = {
/**
* The unique ID of the client.
*/
id?: string;
type?: ClientType;
/**
* The client status. Indicates if the client is able to receive messages or not. Can be pending, inactive, active, or blocked.
*/
status?: 'active' | 'blocked' | 'inactive' | 'pending';
/**
* The ID of the integration that the client was created for. Unused for clients of type sdk, as they incorporate multiple integrations.
*/
integrationId?: string | null;
/**
* The ID of the user on an external channel. For example, the user’s phone number for Twilio, or their page-scoped user ID for Facebook Messenger. Applies only to non-SDK clients.
*/
externalId?: string | null;
/**
* A datetime string with the format `YYYY-MM-DDThh:mm:ss.SSSZ` representing the last time the user interacted with this client.
*/
lastSeen?: string | null;
/**
* A timestamp signifying when the client was added to the user. Formatted as `YYYY-MM-DDThh:mm:ss.SSSZ`.
*/
linkedAt?: string | null;
/**
* The user's display name on the channel.
*/
displayName?: string | null;
/**
* The URL for the user's avatar on the channel.
*/
avatarUrl?: string | null;
/**
* A flat curated object with properties that vary for each client platform. All keys are optional and not guaranteed to be available.
*/
info?: {
[key: string]: unknown;
} | null;
/**
* An object with raw properties that vary for each client platform. All keys are optional and not guaranteed to be available.
*/
raw?: {
[key: string]: unknown;
} | null;
};
export type Device = {
/**
* The unique ID of the device.
*/
id?: string;
/**
* The type of integration that the device represents.
*/
type?: 'android' | 'ios' | 'web';
/**
* A unique identifier for the device, generated client-side by the SDK.
*/
guid?: string;
/**
* The id of the client to which this device is associated.
*/
clientId?: string;
/**
* The device status. Indicates if the device will receive push notifications or not.
*/
status?: 'active' | 'inactive';
/**
* The ID of the integration that the device was created for.
*/
integrationId?: string;
/**
* A datetime string with the format YYYY-MM-DDThh:mm:ss.SSSZ representing the last time the user interacted with this device.
*/
lastSeen?: string;
/**
* The token used for push notifications on Android and iOS devices.
*/
pushNotificationToken?: string | null;
/**
* A flat curated object with properties that vary for each SDK platform. All keys are optional and not guaranteed to be available.
*/
info?: {
[key: string]: unknown;
} | null;
/**
* Version of the mobile app in which the SDK is embedded. Not applicable for devices of type web.
*/
appVersion?: string | null;
};
/**
* The source of the message.
*/
export type Source = {
/**
* An identifier for the channel from which a message originated. May include one of api, sdk, messenger, or any number of other channels.
*/
type: string;
/**
* Identifier indicating which integration the message was sent from. For user messages only.
*/
integrationId?: string | null;
/**
* Message identifier assigned by the originating channel.
*/
originalMessageId?: string | null;
/**
* A datetime string with the format `YYYY-MM-DDThh:mm:ss.SSSZ` representing when the third party channel received the message.
*/
originalMessageTimestamp?: string | null;
/**
* The client from which the user authored the message or activity, if applicable. This field is not applicable in API responses, it is used only in webhook payloads if the `includeFullSource` option is enabled.
*/
client?: Client | null;
/**
* The device from which the user authored the message or activity, if applicable. This field is not applicable in API responses, it is used only in webhook payloads if the `includeFullSource` option is enabled.
*/
device?: Device | null;
};
export type MessageReadable = {
/**
* The unique ID of the message.
*/
id?: string;
/**
* A datetime string with the format `YYYY-MM-DDThh:mm:ss.SSSZ` representing when Sunshine Conversations received the message.
*/
received?: string;
author?: AuthorReadable;
/**
* Details of the system activity that generated this message. This field is used when actions taken by the system generate a persisted message to notify the user or agent of an event that occurred. For example, when a user's Ticket gets closed. This property applies only to informational text messages generated via system events.
*/
activity?: Activity