Skip to content

Repository files navigation

Health AI Conversation Agent

Project Overview

I built a Django-based AI health assistant that engages in natural conversations about health and wellness through the A2A protocol for Telex integration. This intelligent agent provides dynamic, contextual health advice using Google Gemini AI instead of static health tips.

Core Agent Functions

This AI agent performs one main function with advanced capabilities

Intelligent Health Conversations

The agent engages users in natural, dynamic conversations about health topics. It understands context, remembers previous messages, and provides personalized health advice using Google Gemini AI. Users discuss health concerns and receive intelligent, conversational responses.

Project Architecture

Backend Structure

  • Django Framework powers the web application
  • Google Gemini AI provides intelligent conversation capabilities
  • A2A Protocol enables Telex platform integration
  • In-memory session management handles conversation history

Core Components

  • Gemini AI Integration processes natural language conversations
  • A2A Endpoint handles Telex chat interactions
  • Session Management maintains conversation context
  • Health-focused AI specializes in wellness topics

Integration Features

  • JSON-RPC 2.0 Compliance ensures protocol standardization
  • Error Handling provides clear JSON error responses
  • Logging System monitors agent performance and issues
  • Health Monitoring offers service status verification

Technical Implementation

AI Conversation System

The agent uses Google Gemini 2.0 Flash model to provide intelligent health conversations. It maintains session context and delivers personalized advice based on user interactions.

Deployment Configuration

  • Railway Platform hosts the production environment
  • Gunicorn Server handles web requests
  • Environment Variables secure sensitive configuration
  • No database dependency for faster performance

Conversation Features

  • Context-aware responses remember previous messages
  • Health specialization focuses on wellness topics
  • Natural language provides ChatGPT-like experience
  • Session management maintains conversation flow

Telex Integration Process - API Call Flow

1. User Initiates Conversation

A Telex user sends a health-related message to the AI agent within the Telex application.

2. Telex Processes User Request

Telex identifies the health AI agent as the target and formats the user message into A2A protocol JSON-RPC format.

3. Telex Calls Django API

Telex sends an HTTP POST request to the Railway endpoint:

POST https://web-production-8b01c.up.railway.app/api/a2a/health

4. Request Payload Structure

Telex sends this JSON-RPC 2.0 formatted data:

{
  "jsonrpc": "2.0",
  "id": "unique-request-id",
  "method": "message/send",
  "params": {
    "message": {
      "kind": "message",
      "role": "user",
      "parts": [
        {
          "kind": "text",
          "text": "User's health question or message"
        }
      ],
      "messageId": "msg-id",
      "taskId": "task-id"
    },
    "configuration": {
      "blocking": true
    }
  }
}

5. Django Receives and Processes Request

The A2AHealthView class in views.py handles the incoming request:

  • Validates JSON-RPC 2.0 format
  • Extracts user message from the parts array
  • Processes conversation through Google Gemini AI
  • Maintains session context for continuous dialogue
  • Generates intelligent health responses based on conversation history

6. AI Response Generation

The Google Gemini AI analyzes the conversation and generates contextual responses:

  • Understands health context and provides relevant advice
  • Remembers previous messages in the session
  • Asks follow-up questions to understand user needs
  • Provides personalized health recommendations
  • Maintains natural conversation flow

7. Django Sends A2A Response

The application returns this structured JSON-RPC response:

{
  "jsonrpc": "2.0",
  "id": "original-request-id",
  "result": {
    "id": "task-id",
    "contextId": "context-id",
    "status": {
      "state": "completed",
      "timestamp": "2025-10-31T13:19:02.013544Z",
      "message": {
        "messageId": "response-msg-id",
        "role": "agent",
        "parts": [
          {
            "kind": "text",
            "text": "Intelligent health response generated by AI..."
          }
        ],
        "kind": "message",
        "taskId": "task-id"
      }
    },
    "artifacts": [...],
    "history": [...],
    "kind": "task"
  }
}

8. Telex Receives and Displays Response

Telex processes the A2A response and displays the AI-generated health advice to the user in the chat interface.

9. Continuous Conversation Flow

The system maintains session context for ongoing conversations:

  • Session ID management tracks conversation history
  • Context preservation remembers user health topics
  • Natural dialogue flow enables multi-turn conversations
  • Intelligent follow-ups provide comprehensive health guidance

10. AI Specialization

The agent focuses specifically on health and wellness topics:

  • Health advice for nutrition, exercise, and lifestyle
  • Wellness tips for mental health and prevention
  • Medical guidance within safe boundaries
  • Personalized recommendations based on user context

Key Integration Points

  • A2A Protocol Compliance ensures Telex compatibility
  • JSON-RPC 2.0 Standard maintains communication consistency
  • Google Gemini AI provides intelligent conversation capabilities
  • Railway Deployment provides reliable hosting infrastructure
  • Session-based conversations enable contextual dialogue

Example Conversations

User: "How can I improve my sleep quality?" AI: "For better sleep, I recommend establishing a consistent bedtime routine. Try avoiding screens an hour before bed and keeping your room cool and dark. What's your current sleep schedule like?"

User: "I've been feeling stressed at work" AI: "Work stress can impact your health significantly. Try taking short breaks for deep breathing or stretching throughout the day. Have you noticed any specific triggers for your stress?"

User: "What are some healthy breakfast options?" AI: "Great question! For a nutritious breakfast, consider oatmeal with berries, Greek yogurt with nuts, or eggs with whole-grain toast. These options provide sustained energy. What foods do you typically enjoy in the morning?"

This intelligent conversation system creates an engaging experience where Telex users receive personalized, contextual health advice through natural dialogue with an AI health expert.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages