提供: Bright Pattern Documentation
移動先: 案内、 検索
• English

startChat

新規SMSのやり取りを作成します。

リクエスト

構文

startSMSChat(channel: ChatChannelType, address: string, initialObject?: InteractionAssociatedObject): Promise<OperationResult<null>>

:

type ChatChannelType =
   "sms" |

type InteractionAssociatedObject = {

   id: string
   type: string
   displayName: string
   displayType: string
   customFields: Record<string, string>

}

パラメータ

パラメータ パラメータ値 データ型 オプション/必須 説明
channel String 必須 サポートされているチャットチャンネルのいずれかを指定できます。
address String 必須 チャットを開始したい電話番号またはユーザーIDを指定できます。
initialObject
  • id: string
  • type: string
  • displayName: string
  • displayType: string
  • customFields: Record<string, string>
オプション 初期化時に、このチャットに関連付けるオブジェクトを指定できます。たとえば、連絡先からの「クリックしてチャット」アクションの際、その連絡先に関する情報をここに送信することができます。

リクエスト例

   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)
   }

戻り値

null

< 前へ | 次へ >