DEV Community

Amarachii
Amarachii

Posted on

Building a Smart Recipe Agent with Telex & FastAPI — Daily Tips, Ingredient Parsing, and Smart Conversions

Introduction

The Stage 3 HNG Backend task challenged us to build and integrate an AI Agent with Telex.im — a platform for intelligent, workflow-driven automation.
Instead of going for a generic assistant, I built something fun and practical:

A Smart Recipe Agent — an AI-powered cooking assistant that sends daily kitchen tips, parses ingredient lists, performs smart unit conversions, and calculates servings automatically.

This post explains how I designed, built, and integrated it with Telex.im using FastAPI and A2A protocol.


What My Agent Does

✅ Daily Cooking Tips:
Users can message “Get Daily Tip” on Telex, and the agent responds with helpful culinary tips or nutrition insights.

✅ Smart Conversion:
The agent converts ingredient measurements — for example, 2 cups of flour → 250g of flour.

✅ Ingredient Parsing:
It breaks down ingredient text like "½ cup sugar" into:

Quantity → 0.5

Unit → cup

Ingredient → sugar

✅ Serving Calculator:
Easily scale ingredients for multiple servings (e.g., “make this for 6 people” multiplies all quantities).

Together, these features make the agent an intelligent cooking companion that understands and responds naturally through Telex.


Tech Stack & Tools Used

🧩 FastAPI – for creating the backend endpoints

⚙️ Pydantic – for input validation and structured data

☁️ Railway – for cloud deployment

💬 Telex.im – for communication and message streaming via A2A (Agent-to-Agent) protocol


Integration with Telex.im

To make my agent interact with users, I connected it to Telex using a workflow JSON configuration.
Each message sent from Telex (like “Get Daily Tip”) is received by my FastAPI endpoint, processed, and replied back via the A2A webhook.

Example log output when running the agent:

Successfully connected to centrifugo ✅

Agent workflow found ✅

Now running workflow...

making A2A request with data

Got response ✅

If the user requests “Convert 2 cups flour to grams”, the agent reads it, processes the conversion, and replies back directly on Telex with the result.


Project Structure Overview

📦 SmartRecipeAgent
┣ 📜 main.py # FastAPI app
┣ 📜 requirements.txt # Dependencies
┣ 📜 utils.py # Conversion and parsing logic
┣ 📜 telex_handler.py # A2A integration logic
┗ 📜 README.md # Documentation


Challenges & Lessons Learned

Handling A2A 502 errors taught me the importance of proper response validation and quick timeout handling.

Ensuring Telex webhook authentication was correctly formatted avoided multiple disconnection issues.

I learned how Telex workflows pass structured JSON messages and how to debug them using agent logs.


Deployment

I deployed the project on Railway.app, exposing the FastAPI app publicly for Telex to access via HTTPS.
Command used:

uvicorn main:app --host 0.0.0.0 --port $PORT


Results

Once connected, my agent could respond to Telex users instantly with:

💡 Daily cooking inspiration

🥄 Ingredient conversions

🍽️ Scaled recipes for family or single servings

It feels like chatting with a mini smart chef right inside Telex.


Conclusion

The Smart Recipe Agent is a perfect blend of practicality and AI — showing how developers can build intelligent systems that interact conversationally, automate daily tasks, and integrate seamlessly with platforms like Telex.im.

Building this agent for the HNG Stage 3 backend task wasn’t just about code — it was about creating useful intelligence through clean integration.

Top comments (0)