DEV Community

Udoh Gary
Udoh Gary

Posted on

🚀Building CryptoMate — An AI Agent for Real‑Time Crypto Insights on Telex.im

The Challenge

Keeping up with cryptocurrency prices, historical highs/lows, and significant events like halving is time‑consuming and error‑prone. I wanted to build an agent that could:

  • Fetch live pricing for any coin
  • Answer questions like “When was the all‑time high for SHIB?” or “When is the next BTC halving?”
  • Integrate seamlessly into Telex.im so users can chat in a familiar workspace

This is the story of how I built CryptoMate, using the Mastra agent framework and integrated it via Telex’s A2A protocol.


đź§Ş Tech Stack

Here’s what I used:

  • Mastra: for defining the agent and workflows
  • Telex.im: for chat‑agent integration via JSON‑RPC A2A
  • Node.js + Express: backend server for the agent
  • Axios: to fetch data from the CoinGecko API
  • Railway.app: cloud hosting and deployment

⚙️ Architecture Overview

🧑‍💻 User message (via Telex)
        ↓
📡 JSON-RPC Request
        ↓
đź§  Express Server (Node.js)
        ↓
⚙️ Logic Layer 
      ├─ CoinGecko API (for live crypto data)
      └─ Mastra Agent (for natural-language handling)
        ↓
đź’¬ JSON-RPC Response
        ↓
📱 Message displayed on Telex
Enter fullscreen mode Exit fullscreen mode

đź§  Building CryptoMate with Mastra

Step 1. Install Mastra

In the project folder, run:

npm install @mastra/core
Enter fullscreen mode Exit fullscreen mode

This installed the core Mastra package which includes agent, tools, workflows and more. ([npmjs.com][1])

Step 2: Agent setup

import { Agent } from "@mastra/core/agent";
import dotenv from "dotenv";
dotenv.config();

export const cryptoTrackerBot = new Agent({
  name: "crypto-tracker-bot",
  instructions: `
    You are a helpful cryptocurrency assistant.
    You can answer general crypto-related questions,
    provide insights about Bitcoin, Ethereum, and other coins,
    and guide users about the crypto market.
    If the user asks for a price, the data will be fetched from an API,
    so just confirm it politely.
    Keep your responses short, clear, and friendly.
  `,
  model: "gpt-4o-mini",
  openaiApiKey: process.env.OPENAI_API_KEY
});

Enter fullscreen mode Exit fullscreen mode

Step 3: I Used the agent in theserver/backend

In server.js, when you receive a message from Telex, call:

const aiResponse = await cryptoTrackerBot.run(text);
Enter fullscreen mode Exit fullscreen mode

This sends the user’s input to Mastra, gets a response, and you can then send that reply back to Telex in the correct JSON-RPC format.

Step 4: I created the Mastra workflow.json file

This file communicates with Telex the location and function of the Ai agent

{
  "active": true,
  "category": "utilities",
  "description": "A crypto tracker bot that provides real-time prices for cryptocurrencies.",
  "id": "cryptoTrackerBot123",
  "long_description": "You are a helpful crypto tracker bot that fetches live cryptocurrency prices and market information using the CoinGecko API. Users can ask for the price of any coin by name or symbol.",
  "name": "crypto-tracker-bot",
  "nodes": [
    {
      "id": "crypto_tracker_bot_node",
      "name": "crypto-tracker-bot",
      "parameters": {},
      "position": [500, 100],
      "type": "a2a/mastra-a2a-node",
      "typeVersion": 1,
      "url": "cryptomate-production.up.railway.app"
    }
  ],
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "short_description": "Tracks live crypto prices using CoinGecko"
}
Enter fullscreen mode Exit fullscreen mode

đź”— Deploying & Telex Integration

And of course: https://telex.im/ — an AI agent platform like Make, a Slack alternative for bootcamps and communities.


🧠 What Worked & What Didn’t

âś… Worked

  • Mastra made creating the agent straightforward
  • Telex A2A protocol integration was smooth once the JSON format was correct
  • CoinGecko provided reliable price data

❌ Challenges

  • Initial Mastra install issue: had to install via GitHub because npm install mastra failed
  • Workflow trigger sometimes showed “Will the workflow run: False” — resolved by re‑uploading the updated workflow.json and ensuring the URL matched deployment
  • Handling non‑price questions gracefully required adding the timeout logic so Mastra fallback didn’t hang

📌 Tips for Your Own Agent

  • Start simple: price queries first, fallback logic later
  • Test locally with Postman or curl before Telex
  • Use environment variables — never hardcode API keys
  • Monitor logs: what Telex sends vs what your endpoint receives
  • Re‑upload your workflow every time you change the URL

đź’ˇ The project is open to the community!

Feel free to:

  • Check out the source code
  • Open issues or share feedback
  • Contribute enhancements
  • Fork it and build your own version

👉 https://github.com/GodlyPatrick/CryptoMate.git

🎉 Conclusion

Building CryptoMate showed me just how powerful the combination of Mastra + Telex can be for agents. Whether you’re tracking prices, building a dev‑assistant, or automating community workflows, this stack gives you a fast path from idea → live chatbot.
Go ahead and build something cool!


Top comments (0)