Kindly Docs

Go to App
⌘K
▶️Introduction
🔹Getting started with webhooks
🔹Webhooks reference
🔹Message processing
🔹Pattern dialogues
🔹Context memory
🔹Languages
📄Guides and Examples
◽Checking webhook signatures (HMACs)
◽Example: Chat transcript webhook
◽Kindly Chat authentication
◽Inbox backup to S3 bucket
◽Inbox backup to GCS bucket
◽Add the Spinnaker script tag to your site
◽Set up event tracking with Google Tag Manager (GTM)
⚙️APIs
▪️Application API
▪️Chat API
▪️Chat Transcript API
▪️Handover API
▪️Nudge API
▪️Statistics API
▪️iOS SDK
▪️Android SDK
▪️Text Predict API
▪️Ticket webhooks (BETA)
📦Legacy
📝APIs Changelog
🛡️Security
©️License and Disclaimer
Docs powered by Archbee
Introduction

Webhooks reference

A great feature of Kindly is the ability to connect to third-party applications. This is achieved using webhooks. Webhooks can be added to any dialogue or fallback, and are simply sent by HTTP POST by the Kindly backend to a specific URL.

For a step-by-step introduction to webhooks, check out the Getting started with webhooks.

See Example: Chat transcript webhook for an example of a webhook app.

Request payload

The POST request payload from Kindly to your webhook endpoint is a JSON serialized object containing multiple fields.

Here are the most important payload fields and what they represent:

  • organization_id - The ID of the organization to which the chat belongs.
  • bot_id - The ID of the bot to which the chat belongs.
  • chat_id - The chat ID is a UUID that defines the chat the message belongs to. This ID can be found in the inbox, in the URL of the page.
  • user_id - The user ID is a string, provided by the chat client that defines the user who triggered the webhook.
  • chat_labels - The labels associated with this chat.
  • exchange - The dialogue (exchange) object that Kindly found and replied with when triggered by the webhook.
    • exchange_id - The exchange id is a UUID that defines the dialogue that triggered the webhook. It can be found in the URL of the build section, when editing the desired dialogue.
    • language_code - The language code indicating the dialogue language.
  • message - The exact phrase that the user wrote to trigger the webhook.
  • attachments - List of file attachments that user or agent has uploaded to a chat. Read more about it here
  • context- The collected chat context of the conversation. Read more about context Context memory.
  • _links - Linked REST resources object (f.ex. chat transcripts).
    • chat - If your webhook service requires more information about the chat or the previous messages, this can be fetched from the Chat Transcript API with a GET request to the url in _links.chat. Chat Transcript API.
  • source - Source is the name of the chat client that triggered the webhook. It can be one of the following web (chat bubble in the browser), facebook (Facebook Messenger), slack (Slack), app (Application API) or test (app.kindly.ai test chat bubble).
  • web_path - The current URL path for Kindly Chat web clients, which is useful if you are implementing search and want to bias it towards documents related to the current page.
  • web_host - The current URL host for Kindly Chat web clients.
  • web_url - The current URL for Kindly Chat web clients.

Response

An incoming webhook should be answered with a 200 OK JSON response.

Example

Here is an example response showing some of the most common fields.

JSON
{
  "reply": "Hello from server!",
  "buttons": [
    {
      "button_type": "quick_reply",
      "label": "Hello",
      "value": "Hi server!"
    }
  ],
  "image": "https://via.placeholder.com/640x360",
  "image_alt_text": "Optional alternative text for image",
  "new_context": {
    "user_email": "user@example.com"
  },
  "labels": ["label-name-1", "label-name-2"] 
}


Reply

A string of text that will be displayed as a message from the bot.

JSON
{
  "reply": "Text that the bot will answer"
}


To split the message into paragraphs (seperate bubbles) use two consecutive new lines, i.e. \n\n.

JSON
{
  "reply": "Text that the bot will say\n\nText on new line"
}


Buttons

You can attach buttons to the reply. You can define the same types of buttons as you can do in the platform.

It's important to note that the button object needs to be wrapped in an array, even if you only send a single button.

JSON
{
  "reply": "Text that the bot will say",
  "buttons": [
    {
      "button_type": "quick_reply",
      "label": "Hello",
      "value": "Hi"
    },
    {
      "button_type": "link",
      "label": "example.com",
      "value": "https://example.com/"
    },
    {
      "button_type": "email",
      "label": "Email name@example.com",
      "value": "name@example.com"
    },
    {
      "button_type": "phone",
      "label": "Phone 123 456 789",
      "value": "123 456 789"
    },
    {
      "button_type": "dialogue_trigger",
      "label": "Read more",
      "value": "<dialogue-id> or <dialogue-slug>"
    }
  ]
}


Image carousel

You can send one or multiple images.

JSON
{
	"image_carousel": [
		{
			"id": "id1",
			"title": "Carousel title",
			"description": "This is a nice carousel",
			"imageUrl": "https://via.placeholder.com/640x360",
			"linkUrl": "example.com",
			"buttons": [
				{
					"id": "id1",
					"value": "example.com",
					"label": "Open link",
					"button_type": "link"
				},
				{
					"id": "id2",
					"value": "dialogue id of the dialogue to trigger",
					"label": "Trigger dialogue",
					"button_type": "trigger_dialogue"
				}
			]
		}
	]
}



The image_carousel field must be an array of image objects. Every object must contain metadata for a single image.

You can attach buttons to specific images in the carousel. We currently support:

  • trigger_dialogue
  • link
  • quick_reply

New context

If your webhook service computes some new value that you want the chatbot to remember, you can send it as JSON in new_context.

If the key you are adding already exists in the bot's context memory, the value will be overwritten.

JSON
{
  "new_context": {
    "some_key": "some value"
  }
}


Trigger dialogue

Instead of sending a reply defined by the webhook server, you can also trigger a dialogue that you have defined in the Kindly platform.

JSON
{
  "exchange_id": "Dialogue ID"
}


or

JSON
{
  "exchange_slug": "Dialogue slug"
}


The dialogue ID is a UUID, and can be found on the page where you edit the dialogue, or in the URL of the page.

The dialogue slug is an optional value picked by you that can be used in place of the dialogue UUID. You can set the dialogue slug on dialogues with the trigger type.

Labels

You can attach some labels to the chat by passing a labels field:

JSON
{
  "labels": ["label-name-1", "label-name-2"] 
}


You have to use label names. The labels need to exist within the Workspace to be attached, so if they can't be found they won't get triggered but they will not cause any error (i.e. they will just be omitted).

Attachments

The list consists of Attachment objects that include a temporary signed url which is available for 30 minutes after the webhook payload is sent. This means that if you want to keep these attachments you need to download them from the given url and store them somewhere. The supported file types are raw text, documents, images, and PDF.

Here is an example:

TypeScript
type Attachment = {
  created: string;
  name: string;
  url: string;
  size_kb: number;
  status: string;
  type: string;
};

const removeExpiredAttachment = (attachment: Attachment) =>
  new Date(attachment.created) >
  new Date(Date.now() - ATTACHMENT_LIFETIME_MINUTES * 60 * 1000);

async function downloadAndStoreAttachment(attachment: Attachment) {
  const data = await downloadFile(attachment.url); // your own implementation
  await storeFile(data); // your own implementation
}

async function processAttachments(attachments: Attachment[]) {
  return await Promise.allSettled(
    (attachments || [])
      .filter(removeExpiredAttachment)
      .map((attachment) => downloadAndStoreAttachment(attachment))
  );
}


Settings

You can also pass some Chat settings:

  • chatbubble_hide_input_field to disable the Chat input field. Make sure the user has a way to continue the conversation, for example by providing a button that triggers another dialogue.
JSON
{
  "chatbubble_hide_input_field": true
}


Image (deprecated in favor of "Image carousel")

You can also send a single image.

JSON
{
  "image": "https://via.placeholder.com/640x360",
  "image_alt_text": "Optional alternative text for image"
}


The image in the object needs to be a valid image URL. The alt text is the text Kindly will show if the image is unavailable.



Updated 22 Nov 2023
Did this page help you?
PREVIOUS
Getting started with webhooks
NEXT
Message processing
Docs powered by Archbee
TABLE OF CONTENTS
Request payload
Response
Example
Reply
Buttons
Image carousel
New context
Trigger dialogue
Labels
Attachments
Settings
Image (deprecated in favor of "Image carousel")
Docs powered by Archbee