Building Intelligent Workflows: Integrating Mastra A2A Protocol with Telex
Building Intelligent Workflows: Integrating Mastra A2A Protocol with Telex
In the rapidly evolving landscape of AI agents and workflow automation, interoperability between different AI systems has become crucial. This is where the Agent-to-Agent (A2A) protocol comes in, and today I'll walk you through how we integrated Mastra's A2A implementation with Telex, our organization's workflow automation platform.
What is Mastra A2A?
Mastra's Agent-to-Agent (A2A) protocol is a standardized communication layer that allows AI agents to interact seamlessly across different platforms. Built on the JSON-RPC 2.0 specification, it provides a robust framework for agent discovery, task execution, and message exchange.
The A2A protocol ensures that agents can:
- Communicate using a standardized message format
- Execute tasks with proper context management
- Maintain conversation history across interactions
- Return structured artifacts and results
The Architecture
Our implementation consists of three main components:
1. The Mastra Agent
First, we created a weather agent using Mastra's agent framework. This agent serves as our AI worker that processes requests and provides weather information.
2. The Weather Tool
The agent uses a custom tool to fetch real-time weather data from the Open-Meteo API:
3. The A2A Route Handler
The crucial piece that bridges Mastra agents with the A2A protocol is our custom route handler. This handler wraps agent responses in proper A2A format with artifacts and history management:
4. Registering with Mastra
Finally, we register everything with the Mastra instance:
Deployment to Mastra Cloud
Once your Mastra agent is ready, deploying to Mastra Cloud is straightforward:
After deployment, your agent gets a unique A2A endpoint URL:
Integration with Telex
Now comes the exciting part - integrating your Mastra agent with Telex workflows!
Step 1: Create an AI Co-Worker in Telex
In your Telex dashboard, navigate to the AI Co-Workers section and create a new co-worker.
Step 2: Define Your Workflow
In the workflow editor, paste the following workflow definition. The key component here is the node definition which tells Telex how to communicate with your Mastra agent:
Understanding the Node Definition
The magic happens in the nodes array. Let's break down the critical parts:
The most important field is the url - this is the A2A endpoint URL of your deployed Mastra agent. Everything else in the workflow JSON is primarily descriptive metadata about your agent's purpose and behavior.
How It Works
When a user interacts with your Telex workflow:
-
User sends a message through Telex (e.g., "What's the weather in Lagos?")
-
Telex constructs an A2A request:
-
Your Mastra agent processes the request:
- Receives the A2A message
- Extracts the user's question
- Uses the weather tool to fetch data
- Generates a response
-
Returns an A2A-compliant response:
- Telex displays the response to the user in a friendly format
Key Benefits
1. Standardization
The A2A protocol ensures that agents can communicate regardless of their underlying implementation. Your Mastra agent can seamlessly integrate with any A2A-compliant platform.
2. Proper Context Management
The protocol maintains conversation context, task IDs, and message history, enabling multi-turn conversations and stateful interactions.
3. Structured Artifacts
Responses include both human-readable text and structured data artifacts, making it easy to build complex workflows that chain multiple agents together.
4. Error Handling
JSON-RPC 2.0 compliance ensures standardized error responses, making debugging and monitoring straightforward.
5. Flexibility
The same Mastra agent can be used across different platforms (Telex, custom applications, other A2A clients) without modification.
Testing Your Integration
You can test your A2A endpoint directly using curl:
Conclusion
Integrating Mastra's A2A protocol with Telex demonstrates the power of standardized agent communication. By following this approach, you can:
- Build sophisticated AI agents with Mastra's framework
- Deploy them to the cloud with a single command
- Integrate them into complex workflows using Telex
- Maintain clean separation between agent logic and workflow orchestration
The A2A protocol is more than just a technical specification - it's a foundation for building the next generation of interconnected AI systems. Whether you're building weather assistants, data processors, or complex multi-agent systems, this pattern provides a robust and scalable solution.
Next Steps
Want to build your own A2A-enabled agents? Here are some ideas:
- Customer Support Agent: Handle FAQs and ticket routing
- Data Analysis Agent: Process and visualize datasets
- Code Review Agent: Analyze pull requests and suggest improvements
- Content Generator: Create marketing copy or documentation
- Translation Agent: Multi-language content translation
The possibilities are endless. Happy building!
Resources:
- Mastra Documentation
- A2A Protocol Specification
- Telex Platform
- GitHub Repository - Mastra x Telex Example
This implementation was built using Mastra v0.22.2 and deployed to Mastra Cloud in October 2025.