Deploy a Socket Endpoint

Description

With the implementation of a Socket Enpoint you can easily connect your Application with COGNIGY.AI by using our Socket.io interface.

This tutorial covers the necessary steps for creating and connecting a Socket 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 Socket Endpoint on COGNIGY.AI

1 Create and Configure a Socket Endpoint

:link: On COGNIGY.AI

1.1 Create a Socket Endpoint


First you have to create a Endpoint of type "Socket" (see figure 1.1).

Figure 1.1: Socket Endpoint CreationFigure 1.1: Socket Endpoint Creation

Figure 1.1: Socket Endpoint Creation

1.2 Get the Endpoint URL and the URL Token


To sucessfully connect to our Socket.io interface you have to get the Endpoint URL and the URL Token of the current endpoint. You can find both by scrolling up to the top of the endpoint configuration page (see figure 1.2).

Figure 1.2: Socket Endpoint ConfigurationFigure 1.2: Socket Endpoint Configuration

Figure 1.2: Socket Endpoint Configuration

Final Step: Connect Your Application to the Endpoint

:link: On Application of your choice

Requirements
Endpoint URL
URL Token of the Endpoint

Within the application of your choice that uses Socket.io you have to connect by using the in step 1.2 gathered Endpoint URL.

Sending Messages


Messages are sent by using the processInput event with a payload of the following format:

{
  "URLToken":"urlToken",
  "sessionId":"sessionId",
  "userId":"[email protected]",
  "passthroughIP":"127.0.0.1",
  "reloadFlow":"true",
  "resetFlow":"false",
  "resetState":"false",
  "resetContext":"true",
  "text":"Example text",
  "data":{
    "key":"value"
  }
}

You have to paste the URL Token from step 1.2 as a parameter into the request body of your messages.

Receiving Messages


Messages can be received by listening to the output event. The reponses have the following format:

{
  "type":"output",
  "data":
  {
    "text":"responseText",
    "data":
    {
      "key":"value"
    }
  }
}

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


Did this page help you?