はじめに
対話型AIプラットフォーム
チャットボットの概要
自然言語処理(NLP)
ボットの概念と用語
クイックスタートガイド
プラットフォームへのアクセス
ボットビルダーの操作
リリースノート
最新バージョン(英語)
以前のバージョン(英語)
廃止機能(英語)
コンセプト
設計
ストーリーボード
ダイアログタスク
ダイアログタスクとは
ダイアログビルダー
ノードタイプ
インテントノード
ダイアログノード
エンティティノード
フォームノード
確認ノード
ロジックノード
ボットアクションノード
サービスノード
Webhookノード
スクリプトノード
グループノード
エージェント転送ノード
ユーザープロンプト
音声通話プロパティ
イベント ハンドラー
ナレッジグラフ
ナレッジグラフの抽出
ナレッジグラフの構築
ボットにナレッジグラフを追加
グラフの作成
ナレッジグラフの構築
既存のソースからFAQを構築
特性、同義語、停止用語
変数ネームスペースの管理
更新
ノード間の質問と回答の移動
用語の編集と削除
質問と応答の編集
ナレッジグラフの分析
通知タスク
スモールトーク
デジタルスキル
デジタルフォーム
デジタルビュー
デジタルビューとは
パネル
ウィジェット
トレーニング
トレーニングとは
機械学習
機械学習とは
モデル検証
ファンダメンタルミーニング
ナレッジグラフ
示唆
ランキングおよび解決
NLPの詳細設定
NLPのガイドライン
インテリジェンス
インテリジェンスとは
コンテキスト
コンテキストインテント
割り込み
複数インテントの検出
エンティティの変更
デフォルトの会話
センチメント管理
トーン分析
テストとデバッグ
ボットと会話
発話テスト
バッチテスト
会話テスト
デプロイ
チャネル
公開
分析
ボットの分析
NLPメトリクス
会話フロー
Usage Metrics
封じ込め測定
カスタムダッシュボード
カスタムダッシュボードとは
メタタグ
カスタムダッシュボードとウィジェット
ユニバーサルボット
ユニバーサルボットとは
ユニバーサルボットの定義
ユニバーサルボットの作成
ユニバーサルボットのトレーニング
ユニバーサルボットのカスタマイズ
他言語の有効化
ストア
プラントと使用
Overview
Usage Plans
Support Plans
Invoices
管理
ボット認証
複数言語対応ボット
個人を特定できる情報の編集
ボット変数の使用
IVRのシステム連携
一般設定
ボット管理
ハウツー
会話スキルの設計
バンキングボットを作成
バンキングボット – 資金の振り替え
バンキングボット – 残高を更新
ナレッジグラフを構築
スマートアラートの予約方法
デジタルスキルの設計
デジタルフォームの設定方法
デジタルビューの設定方法
データテーブルのデータの追加方法
データテーブルのデータの更新方法
Add Data from Digital Forms
ボットのトレーニング
示唆の使用方法
インテントとエンティティのパターンの使用方法
コンテキスト切り替えの管理方法
ボットのデプロイ
エージェント転送の設定方法
ボット関数の使用方法
コンテンツ変数の使用方法
グローバル変数の使用方法
Web SDK Tutorial(英語)
Widget SDK Tutorial(英語)
ボットの分析
カスタムダッシュボードの作成方法
カスタムタグを使ってフィルタリング
管理
ボット管理者コンソール
ダッシュボード
ユーザーの管理
ユーザーの管理
グループの管理
ロール管理
ボット管理モジュール
登録
ユーザーの招待
招待状の一括送信
ユーザーデータのインポート
Active Directoryからユーザーを同期
セキュリティ/コンプライアンス
シングル サインオンの使用
セキュリティ設定
Billing(日本未対応)
  1. ホーム
  2. Docs
  3. Virtual Assistants
  4. Channel Enablement
  5. Adding WebHook as a channel

Adding WebHook as a channel

Webhook channel provides a generic integration framework to connect your virtual assistant with any external communication systems. Kore.ai XO Platform provides standard request and response APIs to send and receive messages in text format. The end user’s input through a voice, keypad, or any other means must be converted to plain text before it is sent to the Kore.ai XO Platform using the Request API.

Webhook Versions

The platform supports two versions of the Webhook channel i.e., V1.0 and V2.0.

Note: The V2.0 is the recommended version as it provides a scalable request and response format.

Here are the key differences:

Feature Webhook V1.0
Webhook V2.0
Events Not supported Supports ‘on connect’ event
Poll Mechanism Not supported Supported in Synchronous Mode
File Upload in Chunks Not supported Supported

Integration Mode

The platform supports Synchronous and Asynchronous modes of integrations for the Webhook channel. Here are the key differences:

  • Synchronous Mode: The bot responses are directly delivered as response to the incoming requests. The bot will execute the flow, identify the response or responses to be delivered and provide them as the response to the incoming request. Some of the platform functionalities like Alert Tasks, Agent Transfer, Proactive Session Closure messages are not supported in the Synchronous mode. You may consider using the onAlert event through BotKit, learn more.Note: Synchronous Webhook channel requests timeout after 15 secs. We recommend using Asynchronous Webhook Channel if you expect the requests to take beyond 15 seconds
  • Asynchronous Mode: Asynchronous mode is useful if you would like to deliver the bot responses to a different URL other than the incoming request’s URL. You have to configure the POST_URL of your external system to enable the Async mode. The bot responses are asynchronously delivered to this POST_URL. Do note that Kore.ai XO Platform does not provide the service to host the POST URL. You need to host a custom service or use a third-party service for this.

Step 1: Associate an App

To associate an App, follow the below steps:

  1. In the XO Platform, select the assistant to which you want to add the channel.
  2. Go to Deploy > Channels > Webhook.
  3. Go to the Configurations tab of this page and associate this channel with an app.
  4. Enter a Name for the channel.
    1. Select one of these scopes for the app:
      • Allow anonymous users to chat with the assistant: enables anonymous users to interact with the assistant.
      • Auto register new users on Kore.ai XO Platform: Select to control the auto-user registration in Kore.ai if the user assertion is unknown.
    2. In the JWT Signing Algorithms Used For Client App Authentication drop-down list, select one of the following security algorithms:
      • RS256: Select to enable the Public Key field. The Public Key is used by the Kore.ai XO Platform to authenticate the client application.
      • HS256: Select to generate a Secret Key and a Client ID. The Client ID is required for SDK initialization, and the Secret Key used by the Kore.ai XO Platform to authenticate the client application.
    3. Click Create. The app is created and Client ID and Client Secret are generated. Copy the Client ID and Client Secret details
  5. If you want to use JSON Web Encryption (JWE) standard, you can view the Public Key by clicking the link provided below the Client Secret field.
  6. Webhook channel supports both synchronous and asynchronous modes. Depending on your business needs, you can enable one of these modes in the Configurations tab.
  7. (Only for Webhook v2.0) In the Synchronous mode, by default, the Enable the Polling for Webhook v2 option is selected.
  8. Deselect the Enable the Polling in Webhook V2 option to retrieve the complete response, all at once, without the need for polling.
    Note: This option is available only in Webhook v2.0. Learn more.
  9. Select Yes to Enable Channel.
  10. Save the configuration. The Webhook URL in this channel instance is created dynamically.

Step 2: Select the Integration Mode

Use the Webhook URL to establish integration with external communication systems. This URL is available only after enabling the channel.

Step 3: Deploy the Client SDK (Optional)

You may skip this step if you already have a messaging application to integrate with the Webhook channel. Optionally, you can use the Kore.ai Platform’s Web/Mobile SDK libraries to integrate with the Webhook channel. Please ensure to use V2 of the Webhook APIs with synchronous mode for integrating with the client libraries. You can select the API version by going to the Instructions tab of the Webhook channel and scrolling down to Step 4.

After completing these steps, a success message appears on the screen, and a channel request is sent to your Administrator for approval.

  • The channel will be enabled for the end users only after the channel configurations are published. The publish request must be auto-approved or approved by the account admin.
  • Webhook channel instances are included in bot export copy and they are imported when the definition is imported into another bot. The channel instances are imported as placeholders and you need to associate them with a valid app from the target VA.

Step 4: Review Payload Formats

To select the API Version for your integration, go to the Instructions tab of the Webhook channel you are working with. Following are code snippets of the payload formats that you can use to verify the integration. The Webhook API V2 is the latest version and includes a more standardized request and response payload.

Webhook Endpoints

The structure of the Webhook URL of the first instance varies from any additional instances enabled for the bot.

  • In case you have either – only one webhook channel. Or for the first webhook channel in case you have multiple webhook channels configured:
    POST  {{host_url}}/chatbot/hooks/{{bot id}}
  • in case of multi-webhook configuration for the second instance onwards In case you have multiple webhook channels configured, this applies to the second instance onwards:
    POST  {{host_url}}/chatbot/hooks/{{bot id}}/hookInstance/{{webHookId}}  (This is auto-generated)
Query Parameters
Parameter Description
host_url Your Kore.ai Bots Platform URL.
bot id The ID of the bot to which you want to post messages. You can access it from the General Settings page of the bot.

Webhook V1.0

Version 1.0 of the Webhook supports simple request and response interfaces for enabling the communication between your custom channel interface and the platform. It is recommended to use the Webhook V2.0 as it supports standardized and modular payloads for exchanging messages and events.

Interaction Flow

Scenario Synchronous Mode
Asynchronous Mode
Single Response VA responses are sent as a response to the incoming request. VA response is sent to the Post_URL configured as part of the channel configurations.
Multiple consecutive response nodes VA responses are sent as an array to the incoming request. Each of the bot response is sent to the Post_URL configured as part of the channel configurations
Multiple response nodes with service / script / webhook nodes in between The platform completes the service / script / webhook execution and sends the bot responses as an array to the incoming request. Each of the bot response is sent to the Post_URL after processing the relevant service / script / webhook nodes.

Authorization

Invoke the API with JWT in the header with the following syntax:

Authorization: bearer {{JWT}}

Generate JWT using the following header and payload from this page.

Response content type

application/json

Request Parameters

The following are the parameters required/supported in the v1.0 of the Webhook channel

Parameter Name Description
Data Type
Required/Optional Possible Values
session
Details of how the conversation session should be handled. Objects. Optional N/A
new
Parameter to define whether to start a new conversion or continue with the existing. Boolean Optional
  • true
  • false
message
Includes the contents of the incoming request to the bot. Object Required N/A
text
The message text to be sent to the bot. String Required N/A
attachments
The list of attachments to be passed to the bot. Array of Objects Optional
{"url":"https://- - "}
from
Details of the request origin. It usually includes user information. Object Required N/A
id
The unique identity of the user interacting with the bot. String Required Usually a random string, alphanumeric number, email id etc.,
userInfo
The user profile information. Object Optional N/A
firstName
The first name of the user. String Optional N/A
lastName
The last name of the user. String Optional N/A
email
The email address of the user. String Optional N/A
userLevelTags
Array of user level meta tags to be added to the current user. Array of Objects Optional Every tag to be added using “name” and “value’ keys.
sessionLevelTags
Array of session level meta tags to be added to the current conversion session. Array of Objects Optional Every tag to be added using “name” and “value’ keys.
messageLevelTags
Array of message level tags to be added to the current message. Array of Objects Optional Every tag to be added using “name” and “value’ keys.
mergeIdentity
To merge the current conversation with any other conversation in progress. String Optional
  • true
  • false
preferredChannelForResponse
To request the platform to provide a response for a different channel. By default, the platform provides the Webhook channel (instance) related responses. String Optional Any valid channel name.
customData
To send additional custom data from the Webhook channel by including it in the request payload. Object Optional N/A

Sample Request Payload Reference

Below is the Webhook v1 payload format to send messages to the Kore.ai XO Platform:

{ 
	 "session" : {     
                "new" : true
                },
"message": { 
"text": "hi",
"attachments" : 
 	}, 
 	"from": { 
"id": "User01",
	"userInfo" :{
                       "firstName" : “John”,
                       "lastName" : “Doe”,
                       "email" : “john.doe@acme.org”
		}
 },
"metaTags": {
          		"userLevelTags": [
              		{
                  		"name": "customerType",
                  		"value": "Premium"
              		}
          		],
          		"sessionLevelTags": [
              		{
                  "name": "location",
                  "value": "Americas"
              }
],
          "messageLevelTags": [
            		{
                  "name": "messageTag",
                  "value": "messageTag_value"
              }
]
   	    },  
"mergeIdentity" :true,
"preferredChannelForResponse":"rtm",
"customData": {
"name":"John",
"Age":30,
"products": {
"CheckingAccount":"Active",
"LoanAccount":"Inactive",
"CreditCard":"Active"
}
}
 }

You can send additional data from the Webhook channel by including it in the request payload using the customData object. The customData along with the full payload will be available as part of the context.session.BotUserSession.lastMessage object.

Response

The response contains the following fields:

  • to– refers to the user to whom the message is delivered to.
  • from – identity (Stream Id) of the bot from which the response is generated.
  • text – contains the response(s) from the bot. Can be a string, object or an array of strings or objects.
  • endOfTask – indicating whether the task was completed or not, values true or false.
  • endReason– the reason for the task completion – fulfilled, interrupted, or canceled
  • completedTaskId– the id of the dialog task triggered.
  • completedTaskName – the name of the dialog task triggered.

If the bot response is a template, then the JSON object required for rendering the template is included in the ‘text’ field as an object or array of objects.

"customData": {"name":"John","age":30,"cars": 
                             {"car1":"Ford","car2":"BMW","car3":"Fiat"}},

Sample Response for Synchronous Mode

{
  "text": [
            "You have $45,000 in your Salary account.",
            "Let me know if you need any other assistance"
           ],
  "endOfTask": true,
  "endReason": "Fulfilled",
  "completedTaskId": "dg-eb0cc36e-06ac-5bff-8234-e4adf501a2ef",
  "completedTaskName": "show balance"
}

Note: The ‘text’ field can contain a string, object or an array of strings or objects.

Sample Response for Asynchronous Mode

{
"to": "john.doe@kore.com",
"from": "st-b3a3dc49-bd57-5c5d-b12c-8e3776192a4c",
"text": "Your available account balance is $31,439.",
}

For Asynchronous integration mode, the platform sends an acknowledgement response to the incoming request with Status Code as 200. The bot response to be delivered to the user is sent to the Post_URL configured for the channel.

  • The text field can contain a string, object or an array of strings or objects.
  • Separate messages are sent for every bot response to be delivered to the user.
  • The conversation flow related fields like “endOfTask“, “endReason“, “completedTaskId” and “completedTaskName“: “show balance” are delivered as a separate message.

Webhook V2.0

The Webhook V2 API provides a more standardized and modular payload format, and also provides additional conversation management capabilities.

Interaction Flow

Scenario Synchronous Mode
Asynchronous Mode
Single Response VA response is sent as a response to the incoming request. VA response is sent to the Post_URL configured as part of the channel configurations.
Multiple consecutive response nodes VA responses are sent as an array to the incoming request. Each of the bot response is sent to the Post_URL configured as part of the channel configurations
Multiple response nodes with service / script / webhook nodes in between

  • The consecutive messages are delivered to the request along with a ‘pollid’.
  • The platform initiates the execution of service / script / webhook nodes.
  • The client should poll the platform using the ‘pollid’ at short intervals.
  • The platform responds to the poll request with the status of the execution. If the execution is complete, then the response will include the next set of consecutive messages.
Each of the VA response is sent to the Post_URL after processing the relevant service / script / webhook nodes.

Authorization

User Identity

The Webhook V2.0 allows you to authenticate the API call with JWT token user identity. If the user identity (‘from’ field) exists in both request payload and JWT token, then the Webhook v2 validates the user identity. Use the following payload for authentication with user identity:

JWT Payload

{
  "appId": "{{clientId of the bot}}",
  "sub" : "{{random number}}"
  "userIdentity": "{{unique user identity}}",
  "iat" : 161639822 
  }
  • If the userIdentity is not present in JWT, you can validate the userIdentity authentication using the appId and the from value will be used to generate the userId in the Kore platform..
  • If the userIdentity is present in JWT as well as from but both are NOT same, then authentication will be failed and throws an error saying that Invalid access token.
  • The userIdentity is present in JWT and from is present in webhook payload and both userIdentity and from are same then it will check against the authentication against the appId and proceed further.

Request Parameters

The following are the parameters required/supported in the v2.0 of the Webhook channel

Parameter Name Description
Data Type
Required/Optional Possible Values
session
Details of how the conversation session should be handled. Objects. Optional N/A
new
Parameter to define whether to start a new conversion or continue with the existing. Boolean Optional
  • true
  • false
message
Includes the contents of the incoming request to the bot. Object Required N/A
type
The type of incoming message to the platform. String Required
  • text
  • template
  • event
  • formData
val
The value for the incoming message type. String or Object Required
  • If the type = “text” then the val will be String.
  • If the type = “template” or “formData” then the val will be Object.
  • If the type = “event” then the val must be “ON_CONNECT”.
  • if type=”event” then the val must be SESSION_CLOSURE to close an active session.
attachments
The list of attachments to be passed to the VA. Array of Objects Optional
{"url":"https://- - "},
{ "fileName": "Kore_ai_Logo.png", "fileType":"image", "fileId": "6163e17bf60e0xxxxxxxx" }
from
Details of the request origin. It usually includes user information. Object Required N/A
id
The unique identity of the user interacting with the VA. String Required Usually a random string, alphanumeric number, email id etc.,
InteractiveLanguage
The interaction language of the virtual assistant. String Optional Any language that is configured for the VA.
For the list of Supported Bot Languages, read Getting Started with Multilingual Virtual Assistant article.
userInfo
The user profile information. Object Optional N/A
firstName
The first name of the user. String Optional N/A
lastName
The last name of the user. String Optional N/A
email
The email address of the user. String Optional N/A
metaTags
Refers to the meta tags to be added. String Optional N/A
userLevelTags
Array of user level meta tags to be added to the current user. Array of Objects Optional Every tag to be added using “name” and “value’ keys.
sessionLevelTags
Array of session level meta tags to be added to the current conversion session. Array of Objects Optional Every tag to be added using “name” and “value’ keys.
messageLevelTags
Array of message level tags to be added to the current message. Array of Objects Optional Every tag to be added using “name” and “value’ keys.
mergeIdentity
To merge the current conversation with any other conversation in progress. String Optional
  • true
  • false
preferredChannelForResponse
To request the platform to provide a response for a different channel. By default, the platform provides the Webhook channel (instance) related responses. String Optional Any valid channel name.
customData
To send additional custom data from the Webhook channel by including it in the request payload. Object Optional N/A

Sample Request

Below is the Webhook v2.0 payload format to send messages to the Kore.ai XO Platform:

{
  "session": {
    "new": true
  	},
  "message": {
  	"type": "text",
"val": "Hi",
 	"attachments": 
  	},
  "from": {
"id": "",
"userInfo": {
"firstName": "",
"lastName": "",
"email": ""
}
},
  "metaTags": {
"userLevelTags": [
{
                  		"name": "customerType",
                  		"value": "Premium"
              	}
          	],
"sessionLevelTags": [
{
                  "name": "location",
                  "value": "Americas"
 }
],
"messageLevelTags": [
            		{
                  "name": "messageTag",
                  "value": "messageTag_value"
              }
]
    },  
"mergeIdentity" :true,
"preferredChannelForResponse":"rtm",
"customData": {
"name":"John",
"Age":30,
"products": {
"CheckingAccount":"Active",
"LoanAccount":"Inactive",
"CreditCard":"Active"
}
}
}

OnConnect Event Request

The Webhook V2.0 supports the OnConnect event as part of the first user message. You can pass the OnConnect as an event parameter. Here is an example on how to trigger the onConnect event:

{
  "session": {
    "new": true
  },
  "message": {
    "type": "event",
    "val": "ON_CONNECT",
    },
  "from": {
    "id": "",
    "userInfo": {
      "firstName": "",
      "lastName": "",
      "email": ""
    }
  }
}

Response

The response contains the following fields:

  • to– refers to the user to whom the message is delivered to.
  • from – identity (Stream Id) of the bot from which the response is generated.
  • text – contains the response(s) from the bot. Can be a string, object or an array of strings or objects.
  • endOfTask – indicating whether the task was completed or not, values true or false.
  • endReason– the reason for the task completion – fulfilled, interrupted, or canceled
  • completedTaskId– the id of the dialog task triggered.
  • completedTaskName – the name of the dialog task triggered.

Change Conversation Language Request

To change the language of an ongoing conversation, you can pass the interactiveLanguage as a parameter with a value (language code) of one of the VA languages that are configured.

To change the conversation language from English (en) to French (fr), pass the value as “fr” in the interactiveLanguage parameter:

Sample Request

{
  "session": {
    "new": true
  },
  "message": {
    "type": "text",
    "val": "help",
    },
  "from": {
            "id": "userId"
    },
   "to": {
            "id": "streamId"
    },
    "interactiveLanguage":"fr"
  }
}

For the list of Supported Bot Languages codes, read Getting Started with Multilingual Virtual Assistant article.

Close Conversation Session Event Request

The Webhook V2.0 supports the closeConversationSession event as part of the user message. You can pass the Session_Closure as an event parameter.

Here is a sample request to trigger the Session_Closure event:

Sample Request

{
  "session": {
    "new": true
  },
  "message": {
    "type": "event",
    "val": "SESSION_CLOSURE",
    },
  "from": {
            "id": "userId"
    },
   "to": {
            "id": "streamId"
    },
  }
}

Sample Responses

The following are the possible response scenarios.

Sample Response for Synchronous Mode

Scenario 1: Response without need for polling

The platform delivers the message or messages to the client and waits for the user input to continue any ongoing flow or initiate new flow.

Response:
{
 "to": "john.doe@kore.com",
 "from": "st-b3a3dc49-bd57-5c5d-b12c-xxxxxxxxxx",
 "data": [
        {
            "type": "text",
            "val": "The balance in your Salary Account ending with 3984 is $54,883",
            "createdOn": "2022-05-11T06:27:06.764Z",
            "messageId": "ms-16535527-0f27-5116-bee3-xxxxxxxx"
        },
        {
            "type": "text",
            "val": "The balance in your Checking Account ending with 9964 is $21,657",
            "createdOn": "2022-05-11T06:27:07.032Z",
            "messageId": "ms-e3e92480-3d23-50a7-a2e5-xxxxxxxxxxx"
        }
    ],
    "_v": "v2",
    "endOfTask": false,
    "endReason": "Fulfilled",
    "completedTaskId": "dg-79950d7e-cdc6-5ff4-a4be-xxxxxxxxx",
    "completedTaskName": "Show Balance"
}

Scenario 2: Responses with need for polling

If there are one or more Service / Script / Webhook nodes between messages, the platform delivers the messages along with a ‘pollid’ to the incoming request. The client should implement a polling framework to process the flow using the ‘pollid’ provided by the platform.

  • The platform delivers the first message or set of consecutive messages along with a ‘pollid’ to the incoming request
  • The client should make a poll request to the platform using the ‘pollid’ provided by the platform in the response to the original request
  • The response to the poll request can result in one of the following:
    • The ‘status’ is returned as ‘Inprogress’ if the execution of service / script / webhook nodes is still in progress.
    • The response will include the message payload if the execution of service / script / webhook is completed.
    • The response will give an error message if the message for a ‘pollid’ is already delivered to the client.

Response with messages and ‘pollid’

The platform delivers the first message or set of consecutive messages along with a ‘pollid’ to the incoming request. The platform initiates the execution of Service / Script / Webhook nodes.

{
    "data": [
        {
            "type": "text",
            "val": "Sample message for Message0013",
            "createdOn": "2022-05-11T06:48:50.801Z",
            "messageId": "ms-3a3538a7-91b8-5c09-af72-xxxxxxxx"
        }
    ],
    "_v": "v2",
    "pollId": "a69b1077c3541e76253be58aa340950b"
}

Response to poll request when the execution is in progress

URL:	   /chatbot/v2/webhook/:streamId/poll/:pollId
Method: GET
{
   "status": "Inprogress",
   "pollId": "a89627d5b85ba70257871bxxxxxxxxxe",
   "_v": "v2"
}

Response to poll request when the execution is complete

If the processing of service / script / webhook is completed, then the platform responds to the poll request with the message payload.

  • The response format will be the same the regular response.
  • If the flow execution includes execution of service / script / webhook nodes, then the response will include a new ‘pollid’ to be used for subsequent execution.

Response to expired poll request

The messages for a ‘pollid’ are provided by the platform only once. The platform responds with an error message if the client makes a poll request for a ‘pollid’ for which the platform has already delivered the messages.

{
   "errors": [
       {
           "msg": "No data found",
           "code": 400
       }
   ]
}

Response when polling is disabled

When you deselect the Enable the Polling in Webhook V2 option in the Configurations tab, the platform retrieves the complete response, all at once, without the need for polling. Learn more.

Sample Response:

{
"data": [
{
"type": "text",
"val": ""The City Name is Kondapur""The State Name is Telangana"",
"createdOn": "2022-09-29T07:17:52.451Z",
"messageId": "ms-e941520d-a512-5dac-98e3-xxxxxxxxx"
},
{
"type": "text",
"val": "End of Conversation Event",
"createdOn": "2022-09-29T07:17:52.741Z",
"messageId": "ms-e9473e2b-a8f8-5628-9146-xxxxxxxxx"
}
],
"_v": "v2",
"endOfTask": true,
"endReason": "Fulfilled",
"completedTaskId": "dg-2e50c369-ae83-50cb-9abf-xxxxxxxx",
"completedTaskName": "get state name"
}

Response as a Request to Post URL

Then use the pollId from the Response#1 to get the response of the second Message node.

Here is the sample curl to use pollId to fetch the response:

curl --location --request GET 'https://bots.kore.ai/chatbot/v2/webhook/st-xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/poll/a69b1077c3541e762xxxxxxxxx0b' \
--header 'Authorization: bearer ' \
--header 'Content-Type: application/json' \
--data-raw ''

{
    "data": [
        {
            "type": "text",
            "val": "Current weather haze",
            "createdOn": "2022-05-11T06:48:51.545Z",
            "messageId": "ms-0421201b-6c7e-59a6-9246-xxxxxxxxx"
        },
        {
            "type": "text",
            "val": "Let me know if you need any other assistance",
            "createdOn": "2022-05-11T06:48:52.138Z",
            "messageId": "ms-c533f0d8-4495-58f8-9839-xxxxxxxxxx"
        }
    ],
    "_v": "v2",
    "endOfTask": true,
    "endReason": "Fulfilled",
    "completedTaskId": "dg-xxxxx-xxxx-xxxx-xxxx-xxxxxxx",
    "completedTaskName": "current weather"
}

Change Conversation Language Response

Here is the sample response for the change conversation language:

{
    "data": [
        {
            "type": "text",
            "val": ""Voici les tâches que je peux effectuer pour vous.\n a) ADialog \n b) BDialog \n c) Get user data \n 
            d) Raise Complain \n e) Search song \n",
            "createdOn": "2022-07-28T07:06:55.843Z",
             "messageId": "ms-d4ca9e2e-6d2d-xxxx-xxxx-xxxxxxxxx"

        },
        {
            "type": "text",
            "val": "Salut, comment puis-je vous aider?",
            "createdOn": "2022-07-28T07:06:55.843Z",
            "messageId": "ms-d4ca9e2e-6d2d-xxxx-xxxx-xxxxxxxxx"
        }
    ],
    "_v": "v2",
    "endOfTask": true,
    "endReason": "Fulfilled",
    "completedTaskId": "dg-xxxxx-xxxx-xxxx-xxxx-xxxxxxx",
    "completedTaskName": "welcome_task"
}

Close Conversation Session Event Responses

Here are sample responses for the SESSION_CLOSURE:

Response 1: When an active session does exist

{
    "data": [
        {
            "type": "event",
            "val": "SESSION_CLOSURE",
            "eventType": "SESSION_CLOSURE_IGNORED",
             "description": "Active session doesn't exist"
}

Response 1: When an active session exists

{
    "data": [
        {
            "type": "event",
            "val": "SESSION_CLOSURE",
            "eventType": "SESSION_CLOSURE_SUCCESS",
             "description": "session closed successfully",
        }
      ],
   "_v": "v2"
}

Sample Response for Asynchronous Mode

The POST_URL is the customer’s own asynchronous URL to send and receive requests. Kore.ai does not provide any POST _URL for Asynchronous setup because this URL is different from customer to customer.

The following response is an example for a successful asynchronous call:

Request Acknowledgement

{
  "status": "ok"
  "_v": "v2",
  "traceId":"RTM-TRACE-9JOHE3ALB"
}

Response as a Request to Post URL

{
   "data": [
       {
           "type": "text",
           "val": "Please provide your account number",
           "createdOn": "2021-10-11T13:44:34.675Z"
       }
   ],
   "_v": "v2",
}

For Asynchronous integration mode, the platform sends an acknowledgement response to the incoming request with Status Code as 200. The bot response to be delivered to the user is sent to the Post_URL configured for the channel.

  • The ‘text’ field can contain a string, object or an array of strings or objects.
  • Separate messages are sent for every bot response to be delivered to the user.
  • The conversation flow related fields like “endOfTask“, “endReason“, “completedTaskId” and “completedTaskName“: “show balance” are delivered as a separate message.

Support for Attachments

The Webhook API can be used to send attachments from the end users to the bot. Files can be sent in multiple ways

Option 1: Upload Files from Web URLs

You can upload files that are hosted on external services by providing the Web URL of the file location. Make sure that the URL is accessible by the platform. Following is an example:

{
  "session": {
    "new": true
  },
  "message": {
    "type": "{}",
    "val": "image",
    "attachments": ""
  },
  "from": {
    "id": "",
    "userInfo": {
      "firstName": "",
      "lastName": "",
      "email": ""
    }

Option 2: Upload Files to Kore.ai XO Platform

You can upload files directly to the Kore.ai XO Platform, capture the ‘file id’ provided by the platform and share it with the bot during the conversation. This option is supported only when the Webhook v2.0 is used.

Use the following API to upload your file to the platform. These APIs do not require any scopes and are accessible using any of the valid apps present in the bot/account.

Request
URL:  /api/attachments/file/:streamId/:channelType
Method: POST
Body:
{
file:,
fileContext :,
fileExtension : ,
filename:
}

Response

Response: {
fileId:
hash: 
}

You can use the following API to upload file in chunks

Token API

URL: /api/attachments/:streamId/:channelType/token
Method: POST
Headers: {
authorization:bearer jwttoken
}
Body:{
}

Chunk Upload API

URL: /api/attachments/:streamId/:channelType/token/:token/chunk
Method: POST
Headers: {
authorization:bearer jwttoken
}
Body:{
chunk:””,
chunkNo:2
}

Commit API

URL: /api/attachments/:streamId/:channelType/token/:token/chunk
Method: PUT
Headers: {
authorization:bearer jwttoken
}
Body:{
fileContext:””,
filename:””,
totalChunks:””,
fileExtension:””
}

Note: You can also use the filename or fileID to upload a file. For example, use this syntax to upload a file with name and ID: { "fileName": "Kore_ai_Logo%405x.png", "fileType":"image", "fileId": "6163e17bf60e0a7e4799f423" }.

Handle Digital Forms

If your bot has a form that needs user input, the synchronous WebHook channel gets the complete form definition in the response and you need to send the formData in the request when interacting with the bot.

Sample Response

{
    "text": [],
    "form": {
        "formDef": { Formdef },
        "formInitialization": { FormInitialization } //if any
    }
    ..other params if any
}

FormDef
(This is the complete Form definition which is used to render the Form)

{
  "_id": "",
  "refId": "",
  "streamId": "st-####a#d-##fd-#b##-acab-b#f#f######",
  "branding": { 
     "properties": []
    },
  "components": [
    {
     "_id": "fct-#f#e###d-d#b#-###a-#a##-######f###b",
     "refId": "#####f##-###c-###b-##a#-da########1d",
     "metaData": {
         "type": "textField",
         "key": "textField",
         "displayName": "Text Field",
         "name": "TextField0",
         "placeholder": "Provide your input",
         "toolTip": "",
         "isVisible": true,
         "required": false,
         "validations": {
            "validationType": "simple"
            },
         "validateOn": "onBlur"
      },
     "name": "TextField0",
     "type": "textField"
  },
  {
    "_id": "fct-#f#e###d-d#b#-###a-#a##-######f###b",
    "refId": "#####f##-###c-###b-##a#-da########1d",
    "metaData": {
       "type": "textField",
       "key": "textField",
       "displayName": "Text Field",
       "name": "TextField1",
       "placeholder": "Provide your input",
       "toolTip": "",
       "isVisible": true,
       "required": false,
       "validations": {
          "validationType": "simple"
         },
       "validateOn": "onBlur"
      },
      "name": "TextField1",
      "type": "textField"
    },
   {
     "_id": "fct-#f#e###d-d#b#-###a-#a##-######f###b", 
     "refId": "#####f##-###c-###b-##a#-da########1d",
     "metaData": {
        "key": "button",
        "type": "button",
        "displayName": "Submit",
        "name": "Submit",
        "buttonAction": "submit",
        "isVisible": true,
        "buttonStyle": "primary",
        "sourceUrl": ""
       },
     "name": "Submit",
     "type": "button"
     }
    ],
   "description": "regular",
   "displayName": "Form 1",
   "name": "firstForm",
   "type": "regular", 
   (... few other fields)
}

FormInitialization
(This must be used for pre-filling Forms)

{
       "valueMap": {
       "TextField0": "input1",
       "TextField1": "input2"
      }
}

Sample Request

{
    "session": {
        "new": false
    },
    "message": {
        "formData": {
            "formId": "frm-2b2f1ae4-9a3b-5f22-8940-b6827710940f",
            "data": [
                {
                    "componentId": "fct-9f7e487d-d4b8-542a-9a77-7806819f141b",
                    "input": "input1"
                },
                {
                    "componentId": "fct-7aae4eae-2ce7-5d1b-8db1-bb5cfadc3342",
                    "input": "input2"
                }
            ],
            "meta": {}
        }
    },
    "from": {
        "id": ""
    }
    ..others params if any
}

Error Scenarios in Webhook v2 Responses

The following is the failure response for 401 Error:

{	
  "errors": [
    {
      "msg": "Invalid Access token",
      "code": 401
    }
  ],
  "_v": "v2", //versionId
  "_t": "RTM-TRACE-9JOHE3ALB" //traceId
}

The following is the failure response for 429 Error (Rate Limit)

{
  "errors": [
    {
      "msg": "Too Many requests",
      "code": 429
    }
  ],
  "_v": "v2", //versionId
  "_t": "RTM-TRACE-9JOHE3ALB" //traceId
}

The following is the failure response for 504 Error:

{
  "errors": [
    {
      "msg": "The request has been timed-out",
      "code": 504
    }
  ],
  "_v": "v2", //versionId
  "_t": "RTM-TRACE-9JOHE3ALB" //traceId
}

The following is the failure response for 400 Error:

{
  "errors": [
    {
      "msg": "Invalid Request Payload",
      "code": 400
    }
  ],
  "_v": "v2", //versionId
  "_t": "RTM-TRACE-9JOHE3ALB" //traceId
},
メニュー