Connect to AWP
Connect AWP with existing protocols or custom solutions
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 Wire Protocol (AWP) 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 Wire Protocol.
Bridge Eliza with AWP
Now that we have our Eliza server running, let’s show how AWP can connect to any protocol—in this case, the somewhat arcane Telnet protocol.
Project Setup
Let’s create a new project for our AWP bridge:
AWP Recap
The Agent Wire Protocol is a framework that lets you connect agents to clients
in a structured, event-driven way. Agents implement the AbstractAgent
class
from @agentwire/client
and emit events for each piece of content, progress,
etc.
ElizaAgent
We’ll create a special agent class, ElizaAgent
, which:
- Launches a Telnet client to connect to our running Eliza server on localhost:2323.
- Sends the user’s last message to Eliza.
- Waits for the response, then emits AWP events to deliver that text back.
Create a file called src/eliza-agent.ts
:
Explanation
-
Connection We create a TelnetClient and connect to our Eliza Telnet server.
-
User Message We find the last user message from the AWP input. If none exists, we default to “Hello, Eliza”.
-
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 AWP pipeline.RUN_FINISHED
means this run is over.
-
Round-Trip
- Write the user message to Eliza over Telnet.
- Listen for the response from Eliza.
- Emit that response as AWP events.
Putting It All Together
Create a main entry point file src/index.ts
that sets up our AWP agent:
Run the application:
Bridging AWP to Any Protocol
This example demonstrates how to bridge AWP with an existing protocol. The key components are:
- AWP Agent Implementation: Create a class that extends
AbstractAgent
and implements therun
method. - Implement
run()
: Set up an agent or connect to an existing protocol. - Manage agent input: Send the right input to the agent (in our case, it’s the user’s last message).
- Send events: Handle the agent’s response and emit AWP events.
You can apply this pattern to connect AWP 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 AWP 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 Wire Protocol. This tutorial demonstrates how easy it is to adopt AWP with any existing protocol—be it Telnet, WebSocket, custom REST calls, or something entirely else.