Message Service

Service that processes WhatsApp messages through the AI agent, managing conversations and generating responses

Service

Overview

The Message Service is responsible for processing WhatsApp messages through the AI agent service. It manages conversations, generates AI-powered responses, and coordinates with other services for follow-ups and notifications.

View the changelog

Want to know the history of this service? View the change logs

Contact the team

Any questions? Feel free to contact the owners

Sends 2 messages

This service sends messages to downstream consumers

Receives 1 messages

This service receives messages from other services

Architecture diagram

Features

  • AI-Powered Responses: Uses OpenAI/Gemini to generate contextual responses
  • Conversation Management: Tracks conversation state and history
  • Multi-Tenant Support: Handles messages for multiple tenants
  • Channel Integration: Supports WhatsApp, Instagram, and Facebook Messenger
  • Follow-up Scheduling: Automatically schedules follow-up messages when needed

Message Processing Flow

How Message Service Processes Messages

  1. Receive Message

    Message is received from the WhatsApp Message Queue

  2. Validate Payload

    Message payload is validated against WhatsAppMessageSchema

  3. Load Context

    Service loads conversation history, customer data, and tenant configuration

  4. Generate Response

    AI agent generates contextual response based on conversation history and system prompts

  5. Send Response

    Response is sent via WhatsApp API

  6. Schedule Follow-up

    If needed, schedules follow-up message in Follow-Up Queue

Integration

The Message Service integrates with:

  • AI Agent Service: For generating responses
  • Conversation Repository: For managing conversation state
  • Customer Repository: For accessing customer data
  • Tenant Repository: For tenant configuration
  • Channel Repository: For channel settings
  • WhatsApp Client: For sending messages
Event-driven architecture documentation: Impulsell