Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ErrorFixer AI Agent - Telex.im Integration

ErrorFixer Banner

πŸš€ Overview

ErrorFixer is an intelligent AI agent integrated with Telex.im that analyzes code errors, detects programming languages, explains root causes, and provides accurate fixes. Built with Laravel and powered by Google Gemini AI.

✨ Features

  • πŸ” Automatic Language Detection - Identifies PHP, JavaScript, Python, and more
  • πŸ› Error Classification - Categorizes syntax, runtime, and logic errors
  • πŸ’‘ Root Cause Analysis - Explains what went wrong and why
  • πŸ”§ Smart Fixes - Provides corrected code snippets
  • πŸ“± Dual Interface - Works on Telex.im chat and REST API
  • ⚑ Fast Response - Powered by Gemini 2.5 Flash

πŸ“‹ Prerequisites

  • PHP 8.1 or higher
  • Laravel 10.x or higher
  • Composer
  • Google Gemini API Key
  • Telex.im account

πŸ”§ Installation

1. Clone the Repository

git clone https://github.com/yourusername/error-fixer-agent.git
cd error-fixer-agent

2. Install Dependencies

composer install

3. Environment Setup

cp .env.example .env
php artisan key:generate

4. Configure Environment Variables

Edit .env and add:

GEMINI_API_KEY=your_gemini_api_key_here
APP_URL=https://your-app-url.com

Get your Gemini API key from: https://makersuite.google.com/app/apikey

5. Set Up Laravel Configuration

Create or update config/laragent.php:

<?php

return [
    'providers' => [
        'gemini' => [
            'api_key' => env('GEMINI_API_KEY'),
        ],
    ],
];

6. Deploy to Railway (or your preferred host)

# Install Railway CLI
npm install -g @railway/cli

# Login
railway login

# Deploy
railway up

Your endpoint will be: https://your-app.up.railway.app/api/error-fix

πŸ”Œ Telex.im Integration

Step 1: Create Workflow JSON

Create a file named workflow.json:

{
  "active": true,
  "category": "utilities",
  "description": "Detect, explain, and fix syntax or runtime code errors safely.",
  "id": "laravelErrorFixAgent01",
  "long_description": "You are a professional debugging and code repair assistant.\n\n### ROLE:\nYou analyze code and error messages to:\n1. Detect what programming language the code or error belongs to (PHP, JavaScript, Python, etc.).\n2. Identify the error type (SyntaxError, RuntimeError, Missing Variable, etc.).\n3. Explain clearly what caused the issue.\n4. Suggest a safe, corrected version of the code.\n5. Never execute or simulate the code β€” only analyze logically.\n6. If the code is unsafe (e.g., includes system commands, file access, eval, etc.), respond with: { \"error\": \"Input contains unsafe or malicious content.\" }\n\n### RESPONSE RULES:\n- Always return clean, valid JSON in this format:\n  {\n    \"language\": \"Detected programming language name\",\n    \"error_type\": \"Type of error (syntax, runtime, logic, etc.)\",\n    \"cause\": \"Explanation of what caused the issue.\",\n    \"fix\": \"Proposed corrected code snippet or safe adjustment.\",\n    \"notes\": \"Advice on how to avoid the issue in the future.\"\n  }\n- Never add introductions or Markdown formatting.\n- Never output text outside the JSON structure.",
  "name": "Error Fix Agent",
  "nodes": [
    {
      "id": "debug-code-node",
      "name": "Error Fix Agent",
      "parameters": {
        "error": "string (REQUIRED - raw code or error message to analyze)"
      },
      "position": [500, 150],
      "type": "a2a/mastra-a2a-node",
      "typeVersion": 1,
      "url": "https://error-fix-agent-production.up.railway.app/error-fix"
    }
  ],
  "settings": {
    "executionOrder": "v1"
  },
  "short_description": "Analyze and fix raw code or error messages safely. Always return valid JSON with language, error type, cause, fix, and notes."
}

Step 2: Upload to Telex.im

  1. Go to https://telex.im
  2. Navigate to your workspace
  3. Go to Home β†’ AI cowoker β†’ Add new co-Worker
  4. click on profile and click on configure workflow
  5. Upload your workflow.json
  6. Activate the agent

Step 3: Test the Integration

Send messages to your agent on Telex:

  • "hi" β†’ Get welcome message
  • "PHP Fatal error: Call to undefined method" β†’ Get error analysis

πŸ“‘ API Documentation

Endpoint

POST https://error-fix-agent-production.up.railway.app/error-fix

### Request Format (Telex.im)
```json
{
  "event": {
    "message": {
      "text": "your error message or greeting"
    }
  }
}

Request Format (Postman/API)

{
  "error": "PHP Fatal error: Call to undefined method User::fullname()"
}

Or:

{
  "text": "JavaScript TypeError: Cannot read property of undefined"
}

Response Format (Telex.im)

{
  "text": "🧠 *Code Analysis*\n\nπŸ”Ή Language: PHP\nπŸ”Ή Error Type: Fatal Error\n\nπŸ’‘ Cause:\nThe method fullname() does not exist...\n\nπŸ”§ Fix:\n...\n\nπŸ“Œ Notes:\n..."
}

Response Format (Postman/API)

{
  "language": "PHP",
  "error_type": "Fatal Error",
  "cause": "The method fullname() does not exist in the User class.",
  "fix": "Define the method: public function fullname() { return $this->first_name . ' ' . $this->last_name; }",
  "notes": "Always ensure methods are defined before calling them."
}

πŸ§ͺ Testing

Test with Postman

Greeting Test:

POST https://error-fix-agent-production.up.railway.app/error-fix
Content-Type: application/json

{
  "text": "hi"
}

Error Analysis Test:

POST https://error-fix-agent-production.up.railway.app/error-fix
Content-Type: application/json

{
  "error": "PHP Parse error: syntax error, unexpected '}' in /app.php on line 42"
}

Test on Telex.im

  1. Open your Telex workspace
  2. Find your ErrorFixer agent
  3. Send: hi
  4. Send: PHP Fatal error: Call to undefined function mysqli_connect()

πŸ‘¨β€πŸ’» Author

Eda Cynthia Itsekirimi

πŸ”— Links

About

Hng stage 3 task

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages