Deploy a Webhook Endpoint

Description

A Webhook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST.

With the implementation of a Webhook Enpoint you can easily connect your Application with COGNIGY.AI by using a Webhook. The messages you will send to the Endpoint will be processed by COGNIGY.AI and the responses will be sent back to your configured webhook.

This tutorial covers the necessary steps for creating and connecting a Webhook Endpoint. If you want to get information about assigning a Flow to the Endpoint and setting up the Data Management see Endpoints.

One Step Preparation Process

1 Create and Configure a Webhook Endpoint on COGNIGY.AI

1 Create and Configure a Webhook Endpoint

:link: On COGNIGY.AI

Requirements
Webhook URL of your Application
User name for basic authentication
Password for basic authentication

1.1 Create a Webhook Endpoint


First you have to create an Endpoint of the type Webhook (see figure 1.1).

Figure 1.1: Webhook Endpoint CreationFigure 1.1: Webhook Endpoint Creation

Figure 1.1: Webhook Endpoint Creation

1.2 Configure the Webhook Endpoint


Expand the Basic Auth Credentials tab (see figure 1.2). You need to run a Webserver that receives POST calls. Enter the Webhook URL of your application to which the outputs of the assigned flow get sent to. The User and Password fields are only used in case you have defined basic authentication for your Webserver.

1.3 Get the Endpoint URL


Move to the top of the Endpoint Configuration page and copy the Endpoint URL which is displayed above the General Settings (see figure 1.3).

Figure 1.3: Webhook Endpoint URLFigure 1.3: Webhook Endpoint URL

Figure 1.3: Webhook Endpoint URL

Final Step: Connect your Application to the Endpoint

:link: On Application of your choice

Requirements
Endpoint URL

All POST requests that are sent to the Endpoint URL gathered in step 1.3 are processed by the assigned Flow and the triggered outputs are forwarded to the Webhook URL configured in step 1.2. The body of the requests should have the following format:

{
  "userId":"userId",
  "sessionId": "someUniqueId",
  "text":"message text",
  "data": {
    "key": "value"
  }
}

That's it. You should be all set up to use the Webhook Endpoint you've created with a Flow of your choice.

Parameters
userId - a user ID of the user who has access to the REST Endpoint in form of a string
sessionId - a unique ID that is used to track the current conversation in form of a string
text - message text that should get processed by the assigned flow in form of a string
data - message data that should get processed by the assigned flow in form of an object

๐Ÿ“˜

Sending text and data

You can use the Webhook Endpoint to send either text or data to your Flow. You can choose to send both, but at least one is required. If invalid text and invalid data is specified, then the Webhook Endpoint throws an error

๐Ÿ‘

SessionID

The sessionId is a unique identifier that is used to keep the state of a conversation. This means that you should generate a new unique ID whenever a new conversation starts, and not on every message. For testing purposes, you can use whatever string value you like as the sessionId, and change it whenever you want a new conversation to start.


Did this page help you?