Skip to content

Socket.io

Within our Cognigy.AI platform you're able to connect your Cognigy resources to your socket.io client by using our Socket Endpoint integration.

Generic Endpoint Settings

Find out about the generic endpoint settings available with this endpoint on the following pages:

Supports Inject & Notify

You can use the Inject & Notify functionality with this type of Endpoint.

Connect your Application

URL Token

The URL Token is the last part of the displayed Endpoint URL:

In the given example you would connect to https://endpoint-trial.cognigy.ai.

Sending Messages

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

{
    "URLToken": "urlToken",
    "sessionId": "sessionId",
    "userId": "user@cognigy.com",
    "passthroughIP": "127.0.0.1",
    "resetFlow": "false",  // Resets the flow and starts a new one from the beginning
    "text": "Example text",  // Can be skipped with "resetFlow": true
    "data": {
        "key": "value"
    }
}

When the resetFlow flag is set to true, the new flow will start from the beginning. Such payload may or may not have a message. If it does then this message will become the first one in a new flow. Don't forget to set resetFlow flag to false when sending the following messages, otherwise each such message will start a new flow.

Receiving Messages

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

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

Cognigy Socket Client

Cognigy provides a socket client for connecting with a Cognigy Socket Endpoint. The documentation and open source code for this client is available on the Cognigy GitHub Page