For the complete documentation index, see llms.txt. This page is also available as Markdown.

Tunneling: live chat example on AIsuru

Tunneling: a live chat example

In this section we'll see how to implement a live chat using dynamic intents and tunneling. This example will let us explore both how tunneling works and the structure of dynamic intent calls in detail.

The live chat scenario

A live chat is a perfect example to illustrate tunneling because it requires:

  • An ongoing conversation with an external service

  • Maintaining context between messages

  • Handling responses in real time

Dynamic intent structure

To implement the live chat, we configure the dynamic intent with:

  • Name: "LIVE_CHAT"

  • Activation phrases: "I want to speak to an operator", "Live chat", etc.

  • Webhook: URL of the service that manages the live chat

When the user triggers the intent, the webhook receives a request with this structure:

{
  "intentName": "LIVE_CHAT",
  "utterance": "I want to speak to an operator",
  "slotValues": {},
  "currentTag": "string",
  "currentTagAuthenticated": true,
  "contextVars": {},
  "memoriID": "string",
  "sessionID": "string",
  "culture": "en-US"
}

Starting the tunneling

The webhook responds by activating tunneling to take control of the conversation:

From this point:

  1. Every user message is sent directly to the webhook

  2. The Agent no longer processes messages — it just forwards them to the chat service

  3. The operator's replies arrive through the webhook (which passes them to the Agent via the emission)

Managing the conversation

During the chat, each user message generates a request to the webhook:

The webhook responds while keeping the tunneling active:

Closing the chat

When the operator closes the chat, the webhook sends a response that ends the tunneling:

The Agent resumes normal control of the conversation.

The tunneling flag determines who controls the conversation: if true, the webhook is in control; if false, the Agent takes back control.

The live chat example shows how tunneling lets you create complex interactions while keeping a clean, manageable architecture. The same principles apply to many other scenarios that require an ongoing conversation with an external system.

Last updated