> ## Documentation Index
> Fetch the complete documentation index at: https://docs-classic.cognigy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Socket.IO

[Updated in 2026.16.0](https://docs-classic.cognigy.com/release-notes/2026.16.md)

![Socket.IO Endpoint logo](https://mintcdn.com/cognigy-docs-legacy/RomCLoWcsmr9N2pz/_assets/ai/deploy/endpoint-reference/socket-io.svg?fit=max\&auto=format\&n=RomCLoWcsmr9N2pz\&q=85\&s=95a35b7e1628d0cfe957e8e93481d418)

The Socket.IO Endpoint enables you to connect your AI Agent to the Socket.IO client.

## Prerequisites

* Familiarity with the [Socket.IO library](https://socket.io/).
* Setup of the [Cognigy Socket.IO client](https://github.com/Cognigy/SocketClient).

## Generic Endpoint Settings

Learn about the generic Endpoint settings on the following pages:

* [Endpoints Overview](https://docs-classic.cognigy.com/ai/agents/deploy/endpoints/overview)
* [NLU Connectors](https://docs-classic.cognigy.com/ai/platform-features/nlu/external/nlu-connectors/overview)
* [Data Protection & Analytics](https://docs-classic.cognigy.com/ai/agents/deploy/endpoints/data-protection-and-analytics.md)
* [Transformer Functions](https://docs-classic.cognigy.com/ai/for-developers/transformers/overview)
* [Real-Time Translation Settings](https://docs-classic.cognigy.com/ai/agents/deploy/endpoints/real-time-translation-settings.md)
* [Inject and Notify](https://docs-classic.cognigy.com/ai/agents/deploy/endpoints/inject-and-notify.md)
* [Copilot](https://docs-classic.cognigy.com/agent-copilot/configure/copilot-section.md)

## How to Set Up

### Setup on the Cognigy Side

> [accordion] 1. Configure a Socket.IO Endpoint
>
> 1. In the left-side menu of your Project, click **Deploy > Endpoints**.
> 2. On the **Endpoints** page, click **+ New Endpoint**.
> 3. In the **New Endpoint** section, do the following:
>    1. Select the **Socket.IO** Endpoint type.
>    2. Specify a unique name.
>    3. Select a Flow from the list. Save changes.
> 4. In the Endpoint editor, go to the **Configuration Information** section and copy the URL from the **Endpoint URL** field.
>    The Endpoint URL consists of two parts separated by a slash:
>
>    * The server address (`<Socket-Endpoint-URL>`), for example, `https://endpoint-trial.cognigy.ai`.
>    * The token (`<URLToken>`) that comes after the slash, for example, `0e77b9a19f33cb68b3f528b3b28d4b32386162559160ceb9ec85036d83dd8f8b`.
>
>    For further configuration, you need to use these two parts separately.

### Setup on the Third-Party Provider Side

> [accordion] 1. Send a Request
>
> > [tab] Cognigy Socket.IO client
> >
> > ```js theme={null}
> > const { SocketClient } = require("@cognigy/socket-client");
> >
> > (async () => {
> >   // Create the SocketClient with the server address + URL Token + optional options
> >   const client = new SocketClient(
> >     "https://endpoint-trial.cognigy.ai",             // the Socket.IO Endpoint server address
> >     "0e77b9a19f33cb68b3f528b3b28d4b32386162559160ceb9ec85036d83dd8xxx", // the Socket.IO URL token
> >     {
> >       userId: "user@cognigy.com",  
> >       sessionId: "session123", 
> >       forceWebsockets: true 
> >     }
> >   );
> >
> >   // Listen for messages from the AI Agent
> >   client.on("output", (output) => {
> >     console.log("AI Agent:", output.text);
> >     console.log("Additional data:", output.data);
> >   });
> >
> >   // Listen for errors
> >   client.on("error", (error) => {
> >     console.error("AI Agent error:", error.message);
> >   });
> >
> >   // Listen for finalPing (bot done processing)
> >   client.on("finalPing", () => {
> >     console.log("AI Agent finished processing a message");
> >   });
> >
> >   // Connect to the Socket.IO Endpoint
> >   await client.connect();
> >
> >   // Send a message — BASIC
> >   client.sendMessage("Hello from test!");
> >
> >   // Send a message — WITH EXTRA DATA
> >   client.sendMessage(
> >     "Example text with custom data",
> >     {
> >       passthroughIP: "127.0.0.1", // custom IP if needed
> >       resetFlow: false,           // false means: continue Flow
> >       key: "value"                // any custom data for your Flow
> >     }
> >   );
> >
> >   // Reset the Flow if needed
> >   // client.sendMessage(
> >   //   "Starting fresh!",
> >   //   {
> >   //     resetFlow: true
> >   //   }
> >   // );
> > })();
> > ```
>
> > [tab] Other clients
> >
> > Messages are sent using the processInput event with a payload in the following format:
> >
> > ```json theme={null}
> > {
> >     "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"
> >     }
> > }
> > ```
> >
> > | Parameter | Type | Description | Required |
> > | - | - | - | - |
> > | URLToken | String | An authentication token for connecting to the Endpoint. | Yes |
> > | userId | String | The ID of the end user. | Yes |
> > | sessionId | String | The ID used to track the current session and maintain its state. Generate a new unique ID for each new session. For testing, you can use any string and change it whenever you want to start a new session. | Yes |
> > | passthroughIP | String | The IP address of the user, used for logging or tracking purposes. | No |
> > | resetFlow | Boolean | When set to `true`, resets the conversation Flow. This payload may or may not contain a message. If it contains a message, it will be the first in the new Flow. Make sure to set `resetFlow` to `false` for subsequent messages to continue the Flow instead of restarting it. | Yes |
> > | text | String | The text that the assigned Flow should process. | No, if `resetFlow` is `true`. |
> > | data | Object | The data that the assigned Flow should process. | No |

> [accordion] 2. Get a Response
>
> Messages can be received by listening to the `output` event. The responses have the following format:
>
> > [tab] Cognigy Socket.IO client
> >
> > ```text theme={null}
> > AI Agent: I’d be happy to help. Could you please provide your order number?
> > Additional data: {}
> > AI Agent finished processing a message
> > ```
>
> > [tab] Other clients
> >
> > ```json theme={null}
> > {
> >   "type":"output",
> >   "data":
> >   {
> >     "text":"responseText",
> >     "data":
> >     {
> >       "key":"value"
> >     }
> >   }
> > }
> > ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.