Created page with "<translate> =startChat= Create a new SMS interaction. ==Request== ''Syntax'' {| class="wikitable" |startSMSChat(channel: ChatChannelType, address: string, initialObject?: I..." |
Updated via BpDeleteTranslateTags script |
||
| Line 1: | Line 1: | ||
=startChat= | =startChat= | ||
| Line 101: | Line 101: | ||
''null'' | ''null'' | ||
Latest revision as of 04:01, 29 May 2024
startChat
Create a new SMS interaction.
Request
Syntax
| startSMSChat(channel: ChatChannelType, address: string, initialObject?: InteractionAssociatedObject): Promise<OperationResult<null>> |
Where:
| type ChatChannelType =
| "sms" | type InteractionAssociatedObject = { id: string type: string displayName: string displayType: string customFields: Record<string, string> } |
Parameters
| Parameters | Parameter Values | Data Type | Optional/Required | Description |
| channel | String | Required | Allows you to define one of the supported chat channels. | |
| address | String | Required | Allows you to define the phone number or the user id with which you want to start a chat. | |
| initialObject |
|
Optional | Allows you to specify an object associated with this chat upon initialization. For example, on a click-to-chat action from a contact, you can send info about that contact here. |
Example Request
startChatButton.onclick = () => {
const chatChannel = chatChannelInput.value
const chatAddress = chatAddressInput.value
let associatedObject: InteractionAssociatedObject | undefined = undefined
const associatedObjectStr = associatedObjectTextarea.value
if (associatedObjectStr) {
try {
associatedObject = JSON.parse(associatedObjectStr)
} catch (e) {
alert('You have syntax error in the associated object structure. Cannot parse JSON.')
return
}
}
adApi.startChat(chatChannel as any, chatAddress, associatedObject)
}
Return Value
null