Title: [Building WriteRight: My Journey Creating an AI Writing Assistant with Mastra] and Telex.im
🔗 Links Live Demo: https://writing-ai-agent-ylpr.vercel.app/a2a/agent/writingAssistant
Telex.im: https://telex.im @writeright
Mastra: https://mastra.ai Content:
Building WriteRight: My Journey Creating an AI Writing Assistant with Mastra and Telex.im
As part of the Stage 3 Backend Task for HNG Internship, I embarked on an exciting project to build an AI writing assistant similar to Grammarly, integrated with Telex.im. Here’s my journey building WriteRight - an intelligent writing companion that helps users improve thei…
Title: [Building WriteRight: My Journey Creating an AI Writing Assistant with Mastra] and Telex.im
🔗 Links Live Demo: https://writing-ai-agent-ylpr.vercel.app/a2a/agent/writingAssistant
Telex.im: https://telex.im @writeright
Mastra: https://mastra.ai Content:
Building WriteRight: My Journey Creating an AI Writing Assistant with Mastra and Telex.im
As part of the Stage 3 Backend Task for HNG Internship, I embarked on an exciting project to build an AI writing assistant similar to Grammarly, integrated with Telex.im. Here’s my journey building WriteRight - an intelligent writing companion that helps users improve their grammar, style, and overall writing quality.
🎯 The Vision
The goal was clear: create an AI agent that could:
- Fix grammatical errors and spelling mistakes
- Enhance writing style and clarity
- Adapt to different contexts (casual, professional, academic, creative)
- Provide personalized feedback using memory
- Integrate seamlessly with Telex.im
🛠️ Technical Architecture
Choosing the Right Tools
After evaluating several options, I settled on:
- Mastra Framework: The required framework for TypeScript/JavaScript developers in this task
- Google Gemini: For AI text processing and improvements
- Express.js: For the server and API endpoints
- Vercel: For seamless deployment
The Development Journey
Phase 1: Setting Up Mastra Agents
The first challenge was understanding Mastra’s agent system. Unlike traditional API development, Mastra uses an agent-oriented approach where each agent has:
- Instructions: Detailed system prompts defining behavior
- Tools: Custom functions the agent can call
- Memory: Persistent storage for user preferences
- Scorers: Evaluation metrics for agent performance
javascript
export const writingAgent = new Agent({
name: 'WriteRight Writing Assistant',
instructions: `You are WriteRight, an advanced AI writing assistant...`,
model: google('gemini-1.5-flash'),
tools: { grammarCheckTool, userPreferencesTool },
memory: new Memory({/* ... */}),
});
Phase 2: Building the Tools
I created specialized tools for different writing improvement aspects:
Grammar Check Tool: Analyzes text for grammatical errors
User Preferences Tool: Accesses user writing history from memory
Update Preferences Tool: Saves user preferences and learning progress
The memory system was particularly interesting - it allows WriteRight to remember user preferences and common mistakes, providing truly personalized feedback over time.
Phase 3: Telex.im A2A Integration
The A2A (Agent-to-Agent) protocol was the bridge to Telex.im. This required:
Creating a specific endpoint format
Proper request/response mapping
Markdown formatting for rich responses
javascript
app.post('/a2a/agent/writingAssistant', async (req, res) => {
// Handle Telex.im webhooks
const response = {
type: 'message',
content: {
text: formattedResponse,
format: 'markdown'
}
};
});
Phase 4: Deployment Challenges
The initial deployment had TypeScript compilation issues. After several attempts, I switched to a pure JavaScript implementation which deployed successfully to Vercel.
🎉 Key Features Implemented
1. Context-Aware Processing
WriteRight adapts its suggestions based on the writing context:
Casual: Preserves informal tone while fixing errors
Professional: Enhances business-appropriate language
Academic: Enforces formal scholarly standards
Creative: Enhances storytelling and expressive elements
2. Personalized Learning
The memory system tracks:
User's preferred writing tone
Common mistakes they make
Writing goals and proficiency level
Improvement history across sessions
3. Real-time Feedback
Instant processing with clear explanations:
Shows corrected text
Explains why changes were made
Offers alternative phrasing
Provides constructive suggestions
📈 Lessons Learned
What Worked Well
Mastra's Memory System: Incredibly powerful for building personalized AI experiences
Google Gemini: Reliable and cost-effective for text processing
Express.js Simplicity: Perfect for quick API development
Vercel Deployment: Seamless and reliable hosting
Challenges Overcome
TypeScript Build Issues: Solved by switching to JavaScript
A2A Protocol Learning Curve: Required understanding Telex.im's expected format
Memory Integration: Getting the tool context right for memory access
🔮 Future Enhancements
While the current implementation is functional, there's room for growth:
Integration with more grammar checking APIs
Advanced style analysis
Multi-language support
Collaborative writing features
Advanced analytics dashboard
🚀 Try It Yourself
WriteRight is live and integrated with Telex.im! You can:
Import the workflow into your Telex.im workspace
Mention @WriteRight in any channel
Get instant writing improvements
Live Demo: [Your Vercel App URL]
Telex Workflow: [Your Workflow JSON]
💭 Final Thoughts
Building WriteRight was an incredible learning experience that taught me:
How to design and implement AI agents
The importance of proper error handling in AI systems
How to integrate with modern collaboration platforms
The value of user-centric design in AI tools
The Mastra framework proved to be a powerful tool for building intelligent agents, and Telex.im's A2A protocol made integration straightforward once understood.
This project demonstrates how AI can enhance everyday writing tasks, making communication clearer and more effective for everyone.
Built with ❤️ for the HNG Internship Stage 3 Backend Task