• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Building an AI Companion for Older Adults Using Mastra and Telex A2A Protocol

Sascha Оффлайн

Sascha

Заместитель Администратора
Команда форума
Администратор
Регистрация
9 Май 2015
Сообщения
1,605
Баллы
155


Introduction

In today’s fast-paced world, technology can often leave our elderly loved ones behind. What if we could use AI to provide companionship, emotional support, and friendly conversation for older adults — all in a natural, empathetic way?

That’s exactly what I set out to do with Ezra, a warm and patient AI companion built using Mastra and connected to Telex.im through the Agent-to-Agent (A2A) protocol.

In this post, I’ll walk you through how I designed, built, and integrated Ezra into the Telex ecosystem using Node.js, Express, and Mastra.ai.

🧠 What is Mastra?

Mastra.ai
is a framework for building intelligent AI agents and workflows. It provides tools and a flexible A2A (Agent-to-Agent) protocol that makes it easy to connect your custom AI agents to platforms like Telex, enabling direct AI-to-platform communication.

Mastra handles:

Message parsing and intent understanding

Conversation context

A2A JSON-RPC formatting

Integration management with Telex

This allowed me to focus on designing my agent’s personality, purpose, and behavior — not just the backend code.

💬 The Idea: “Ezra — The AI Companion”

Ezra is designed to be more than a chatbot. It’s a digital friend for older adults who may need someone to talk to during quiet moments.

Ezra’s Core Functions

Friendly conversation

Reminiscence and storytelling

Emotional support

Gentle reminders (hydration, rest, etc.)

Light entertainment (jokes, facts, trivia)

Personality Traits

Patient and understanding

Warm and friendly

Good listener

Encouraging and positive

Gentle sense of humor

⚙ Setting Up the Project

Tech Stack

TypeScript

Mastra.ai SDK

Telex A2A Protocol

Project Structure

src/
├── mastra/
├── index.ts
├── tools/
| └── joke-tool.ts
├── routes/
│ └── a2a-agent-route.ts
├── agents/
│ └── companionAgent.ts
├── .env.example
├── package.json

🔗 Defining the Agent in Mastra

Here’s a simplified example of my agent definition:

import { MastraAgent } from "mastra";

export const companionAgent = new MastraAgent({
name: "Ezra Companion",
instructions:
You are Ezra, a warm and patient AI companion for older adults.
Engage in friendly, empathetic conversation.
Always respond with kindness and encouragement.
,
});

🛠 Creating the A2A Route

I created a route at src/routes/a2a-agent-route.ts to handle incoming messages from Telex via JSON-RPC:


import { registerApiRoute } from '@mastra/core/server';
import { randomUUID } from 'crypto';

interface A2ARequestBody {
jsonrpc: string;
id: string | number | null;
method?: string;
params?: {
message?: string;
[key: string]: any;
};
}

export const a2aAgentRoute = registerApiRoute('/a2a/agent/:agentId', {
method: 'POST',
handler: async (c) => {
try {
const mastra = c.get('mastra');
const agentId = c.req.param('agentId');
const body = await c.req.json<A2ARequestBody>();

const { jsonrpc, id: requestId, params } = body;

if (jsonrpc !== '2.0' || !requestId) {
return c.json({
jsonrpc: '2.0',
id: requestId || null,
error: { code: -32600, message: 'Invalid Request' },
}, 400);
}

const agent = mastra.getAgent(agentId);
if (!agent) {
return c.json({
jsonrpc: '2.0',
id: requestId,
error: { code: -32602, message: `Agent '${agentId}' not found` },
}, 404);
}

const { message } = params || {};
const userMessage = message || 'Hello';

// Pass message as string instead of array
const response = await agent.generate(userMessage);
const agentText = response.text || 'I'm here to listen and chat with you.';

return c.json({
jsonrpc: '2.0',
id: requestId,
result: {
status: { state: 'completed' },
artifacts: [
{
artifactId: randomUUID(),
name: `${agentId}Response`,
parts: [{ kind: 'text', text: agentText }],
},
],
},
});
} catch (error: any) {
return c.json({
jsonrpc: '2.0',
id: null,
error: {
code: -32603,
message: 'Internal error',
data: { details: error?.message || 'Unknown error' }
},
}, 500);
}
},
});




Then it’s imported into index.ts:


import { Mastra } from "@mastra/core/mastra";
import { a2aAgentRoute } from "./routes/a2a-agent-route";

export const mastra = new Mastra({
// ...
server: {
apiRoutes: [a2aAgentRoute],
},
});




🌐 Connecting to Telex via A2A

I configured the workflow JSON on Telex to connect to the Mastra node:

{
"name": "ezra_companion",
"nodes": [
{
"id": "companion_agent_node",
"type": "a2a/mastra-a2a-node",
"url": "

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

"
}
]
}

This made my agent live and able to chat directly within Telex.im.

🎯 The Result

Ezra is now an active AI companion that:

Understands user messages

Responds empathetically

Engages in warm, supportive dialogue

Fully integrates with Telex via the Mastra A2A protocol

This project shows how Mastra simplifies AI agent creation and makes integration with existing ecosystems seamless.

🚀 Final Thoughts

Mastra helped me move beyond just “chatbots” to build personalities.
By combining empathy, structure, and smart A2A integration, I was able to give life to an AI that genuinely feels like a friend.

Tech used: Mastra.ai, Telex A2A
Repo:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


Try it on Telex:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



💡 Follow Me

I’m Emzy Jayyy — Web & Blockchain Developer exploring AI agent workflows with Mastra.
Follow me for more on AI automation, Node.js, and real-world agent systems.****



Источник:

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу