How I built an AI agent that generates complete brand identities including names, taglines, stories, and domain recommendations using Mastra framework
tags: ai, typescript, agents, nodejs
Ever struggled to come up with the perfect brand name for your startup? What if an AI could not only suggest creative names but also check domain availability, write compelling taglines, and craft your brand story—all in seconds?
That’s exactly what I built with BrandGenie, an AI branding assistant powered by Mastra and deployed on Telex.
  
  
  🎯 What is BrandGenie?
Try it here: BrandGenie on Telex
BrandGenie is an AI agent that generates complete brand identity packages. Simply describe your business idea (e.g., “AI-powered fitness coaching app”), and BrandGenie provides:
- 5 creative, memorable brand names
 - Domain availability recommendations
 - A catchy tagline
 - A compelling brand story
 - Target audience insights
 
All formatted in beautiful markdown, ready to use.
  
  
  🤖 What is Telex?
Telex is an AI agent platform like Zapier or Make.com, but specifically designed for conversational AI workflows. Think of it as a Slack alternative for education, communities, and bootcamps where AI agents can interact with users naturally through chat interfaces.
  
  
  🛠️ Tech Stack
- Backend Framework: Mastra – A modern TypeScript framework for building AI agents
 - Language Model: Google Gemini 2.5 Flash
 - Deployment: Mastra Cloud
 - Integration Platform: Telex (A2A protocol)
 - Runtime: Node.js with TypeScript
 
  
  
  🏗️ Architecture Overview
The application consists of three main components:
- Agent – The conversational AI that orchestrates the branding process
 - Tool – The domain checking and content generation logic
 - Workflow – Manages the execution flow and data transformation
 
User Input → Telex → Mastra Cloud → Agent → Tool → Response
  
  
  📚 Mastra Features Used
  
  
  1. Agent System
Mastra’s Agent system provides the conversational intelligence layer. Here’s how I configured BrandGenie:
import { Agent } from '@mastra/core/agent';
import { Memory } from '@mastra/memory';
export const brandGenieAgent = new Agent({
  name: 'BrandGenie Agent',
  instructions: `
    You are an AI branding assistant called BrandGenie.
    Generate 5 creative brand names, then call the brandGenieTool 
    to check domain availability and create a complete brand package.
  `,
  model: 'google/gemini-2.5-flash',
  tools: { brandGenieTool },
  memory: new Memory({
    storage: new LibSQLStore({
      url: 'file:../mastra.db',
    }),
  }),
});
Key Features:
- Natural language understanding through LLM integration
 - Memory system for context retention across conversations
 - Tool calling capability for domain checking
 
  
  
  2. Tool System
Mastra’s Tool system allows agents to perform specific actions. My brandGenieTool generates the complete brand identity:
import { createTool } from '@mastra/core/tools';
import { z } from 'zod';
export const brandGenieTool = createTool({
  id: 'brandgenie-tool',
  description: "'Generates complete brand identity package',"
  inputSchema: z.object({
    idea: z.string().describe('Business idea'),
    customNames: z.array(z.string()).optional(),
  }),
  outputSchema: z.object({
    text: z.string().describe('Markdown-formatted brand identity'),
    format: z.literal('markdown'),
  }),
  execute: async ({ context }) => {
    // Industry detection
    const industry = detectIndustry(context.idea);
    // Generate brand names, taglines, and story
    // Return formatted markdown
  },
});
Key Features:
- Type-safe input/output validation with Zod schemas
 - Industry-specific domain recommendations
 - Structured markdown output
 
  
  
  3. Workflow System
Mastra Workflows orchestrate the agent execution:
import { createStep, createWorkflow } from '@mastra/core/workflows';
const generateBranding = createStep(brandGenieAgent);
const brandGenieWorkflow = createWorkflow({
  id: 'brandgenie-workflow',
  inputSchema: z.object({
    idea: z.string(),
  }),
  outputSchema: z.object({
    text: z.string(),
  }),
})
  .map(async ({ inputData }) => ({
    prompt: `Generate brand names for: ${inputData.idea}`
  }))
  .then(generateBranding)
  .commit();
Key Features:
- Declarative workflow definition
 - Data transformation between steps
 - Type-safe execution pipeline
 
  
  
  4. Observability & Logging
Mastra’s built-in observability helps monitor agent performance:
export const mastra = new Mastra({
  agents: { brandGenieAgent },
  workflows: { brandGenieWorkflow },
  logger: new PinoLogger({
    name: 'Mastra',
    level: 'info',
  }),
  observability: {
    default: { enabled: true },
  },
});
  
  
  5. A2A Protocol Integration
For Telex integration, I implemented Mastra’s A2A (Agent-to-Agent) protocol:
import { registerApiRoute } from "@mastra/core/server";
export const a2aAgentRoute = registerApiRoute("/a2a/agent/:agentId", {
  method: "POST",
  handler: async (c) => {
    const mastra = c.get("mastra");
    const agentId = c.req.param("agentId");
    const body = await c.req.json();
    // JSON-RPC 2.0 format handling
    const agent = mastra.getAgent(agentId);
    const response = await agent.generate(messages);
    // Return A2A-compliant response
  },
});
  
  
  6. Scoring System
Implemented custom LLM-as-judge scorer to evaluate brand creativity:
import { createScorer } from '@mastra/core/scores';
export const creativityScorer = createScorer({
  name: 'Brand Creativity & Relevance',
  type: 'agent',
  judge: {
    model: 'google/gemini-2.5-flash',
    instructions: 'Evaluate brand name creativity and relevance...',
  },
})
  .analyze({
    outputSchema: z.object({
      creative: z.boolean(),
      relevant: z.boolean(),
      professional: z.boolean(),
    }),
  })
  .generateScore(({ results }) => {
    // Calculate creativity score
  });
  
  
  🎨 Domain Detection Logic
One interesting challenge was detecting the right domain extensions for different industries:
const DOMAIN_PRESETS: Record<string, string[]> = {
  tech: ['.com', '.io', '.dev', '.ai', '.co'],
  ecommerce: ['.com', '.shop', '.store', '.co', '.ng'],
  education: ['.edu.ng', '.org', '.academy', '.com'],
  finance: ['.com', '.finance', '.co', '.biz'],
  // ... more industries
};
function detectIndustry(idea: string): string {
  const text = idea.toLowerCase();
  if (text.includes('tech') || text.includes('software')) return 'tech';
  if (text.includes('ecommerce') || text.includes('store')) return 'ecommerce';
  // ... more detection logic
  return 'default';
}
  
  
  🚀 Deployment & Integration
  
  
  Deploying to Mastra Cloud
# Deploy the agent
mastra deploy
# Verify deployment
curl https://brandgenie.mastra.cloud/health
  
  
  Connecting to Telex
Telex integration uses JSON configuration:
{
  "active": true,
  "category": "utilities",
  "name": "brandgenie_agent",
  "description": "Generates creative brand names and checks domain availability",
  "nodes": [{
    "id": "brandgenie_agent_node",
    "name": "BrandGenie Agent",
    "type": "a2a/mastra-a2a-node",
    "url": "https://brandgenie.mastra.cloud/a2a/agent/brandGenieAgent"
  }]
}
  
  
  🎯 Key Learnings
  
  
  1. Type Safety is Critical
Mastra’s integration with Zod made schema validation seamless and caught many bugs early.
  
  
  2. Tool Design Matters
Initially, I tried checking domain availability via external APIs, which caused timeouts. Switching to intelligent suggestions without real-time checking improved performance dramatically.
  
  
  3. Agent Instructions are Code
Clear, detailed instructions in the agent configuration directly impact output quality. Treat them like critical business logic.
  
  
  4. A2A Protocol Standardizes AI Communication
Using the A2A protocol made integration with Telex straightforward and could enable future integrations with other platforms.
  
  
  📊 Performance Optimization
  
  
  Before:
- Domain checking: 100+ API calls
 - Response time: 5-8 minutes ❌
 
  
  
  After:
- Smart domain suggestions
 - Response time: 2-3 seconds ✅
 
The key was moving from real-time domain checking to intelligent recommendations based on industry patterns.
  
  
  🔮 Future Enhancements
- Logo Generation – Integrate DALL-E for brand logo concepts
 - Color Palette Suggestions – AI-powered brand color schemes
 - Social Media Handles – Check Twitter, Instagram availability
 - Competitor Analysis – Research similar brand names
 - Multi-language Support – Generate names in different languages
 
  
  
  💡 Why Mastra?
After trying several AI frameworks, here’s why Mastra stood out:
- TypeScript-first – Great DX with full type safety
 - Batteries included – Agent, tools, workflows, memory, scoring all integrated
 - Production-ready – Built-in observability and logging
 - Cloud deployment – One command to deploy
 - A2A protocol – Standards-based agent communication
 
  
  
  🎓 Lessons for AI Agent Builders
- Start with clear use cases – Don’t build a general chatbot; solve specific problems
 - Design for latency – Users expect fast responses; optimize early
 - Use structured output – Markdown formatting makes AI responses more useful
 - Implement graceful degradation – Handle API failures elegantly
 - Monitor and iterate – Use scoring and observability to improve over time
 
  
  
  🔗 Resources
  
  
  🙋♂️ About the Project
BrandGenie started as a learning project to explore AI agent development but evolved into a practical tool for entrepreneurs and marketers. The combination of Mastra’s powerful framework and Telex’s distribution platform made it possible to go from idea to production in just a few days.
  
  
  💬 Try It Yourself
Want to build your own AI agent? Here’s a quick start:
npm install @mastra/core
npx mastra init
Then follow the Mastra documentation to create your first agent!
What would you build with an AI agent framework? Drop your ideas in the comments! 👇
If you found this helpful, consider giving it a ❤️ and following me for more AI and backend development content.
