Skip to main content
In this tutorial, you’ll learn how to resurrect one of the first chatbots in computer science history—the famous Eliza, originally created in the 1960s! This not only pays homage to computing’s past but also demonstrates how the Agent User Interaction Protocol (AG-UI) can integrate seamlessly with any protocol. Let’s get started.

Prerequisites

Make sure to have the following installed:

Running Eliza via Docker

Let’s run Eliza in a Docker container and connect to her via telnet.
Once the container is running, we can connect to Eliza.
You should see Eliza greet you with:
Type quit to exit Telnet. Congratulations! You’ve just brought Eliza to life. Now let’s connect her to the Agent User Interaction Protocol.

Bridge Eliza with AG-UI

Now that we have our Eliza server running, let’s show how AG-UI can connect to any protocol—in this case, the somewhat arcane Telnet protocol.

Project Setup

Let’s create a new project for our AG-UI bridge:

AG-UI Recap

The Agent User Interaction Protocol is a framework that lets you connect agents to clients in a structured, event-driven way. Agents implement the AbstractAgent class from @ag-ui/client and emit events for each piece of content, progress, etc.

ElizaAgent

We’ll create a special agent class, ElizaAgent, which:
  1. Launches a Telnet client to connect to our running Eliza server on localhost:2323.
  2. Sends the user’s last message to Eliza.
  3. Waits for the response, then emits AG-UI events to deliver that text back.
Create a file called src/eliza-agent.ts:

Explanation

  1. Connection We create a TelnetClient and connect to our Eliza Telnet server.
  2. User Message We find the last user message from the AG-UI input. If none exists, we default to “Hello, Eliza”.
  3. Emitting Events
    • RUN_STARTED means the agent started processing the request.
    • TEXT_MESSAGE_START / TEXT_MESSAGE_CONTENT / TEXT_MESSAGE_END together send the agent’s textual response to the AG-UI pipeline.
    • RUN_FINISHED means this run is over.
  4. Round-Trip
    • Write the user message to Eliza over Telnet.
    • Listen for the response from Eliza.
    • Emit that response as AG-UI events.

Putting It All Together

Create a main entry point file src/index.ts that sets up our AG-UI agent:
Run the application:

Bridging AG-UI to Any Protocol

This example demonstrates how to bridge AG-UI with an existing protocol. The key components are:
  1. AG-UI Agent Implementation: Create a class that extends AbstractAgent and implements the run method.
  2. Implement run(): Set up an agent or connect to an existing protocol.
  3. Manage agent input: Send the right input to the agent (in our case, it’s the user’s last message).
  4. Send events: Handle the agent’s response and emit AG-UI events.
You can apply this pattern to connect AG-UI to virtually any protocol or service:
  • HTTP/REST APIs
  • WebSockets
  • MQTT for IoT devices
  • any other protocol
By following this pattern of creating protocol adapters around your AG-UI agents, you can make your AI agents available through any communication channel while maintaining a consistent agent implementation.

Conclusion

Congratulations! You’ve resurrected the first historical chatbot by serving Eliza over Telnet and bridged it to the Agent User Interaction Protocol. This tutorial demonstrates how easy it is to adopt AG-UI with any existing protocol—be it Telnet, WebSocket, custom REST calls, or something entirely else.