Skip to content

API Reference

Chatbot & AI Service

Health Check

GET /health

Simple health check endpoint to verify the service is running.

Response:

{
  "status": "ok"
}

Webhook Verification

GET /webhook

Endpoint used by external services (e.g., WhatsApp, Facebook) to verify the webhook URL.

Authentication: Query Parameter hub.verify_token must match your server's VERIFIABLE_TOKEN.

Query Parameters: - hub.mode: Mode of verification (e.g., "subscribe"). - hub.verify_token: The verification token to validate the request. - hub.challenge: A string that the endpoint must echo back.

Response: - 200 OK: Returns hub.challenge as plain text. - 403 Forbidden: If tokens do not match.

Receive Webhook Event

POST /webhook

Main entry point for receiving incoming messages from WhatsApp or the Internal Job Queue.

Authentication: Internal requests check for X-Sender header.

Request Body:

Scenario A: WhatsApp Message

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "...",
      "changes": [...]
    }
  ]
}

Scenario B: Internal Reminder (Laravel Job)

{
  "recipient_phone_number": "...",
  "reminder": {
    "body": "Detailed reminder text..."
  }
}

Response:

{
  "status": true,
  "message": "Reminder successfully sent to patient",
  "data": "AI Response string..."
}

Update Patient Profile (PIP)

POST /update_patient_profile

Updates the patient's management plan and generates relevant reminders.

Request Body:

{
  "patient_phone_number": "string",
  "new_management_plan": "string",
  "patient_name": "string"
}

Response:

{
  "status": "success",
  "message": "Patient Profile successfully updated",
  "data": {
    "patient_phone_number": "string",
    "reminders": [
      {
        "reminder_text": "string",
        "reminder_time": "morning",
        "is_active": true
      }
    ]
  }
}

Clinical Decision Support (CDS)

POST /cds

Provides AI-assisted insights (e.g., processing patient issues, assisting doctors).

Request Body:

Scenario: Issues Assistant

{
  "required_assistant": "cds_patient_issues_assistant",
  "patient_data": {
    "patient_phone_number": "..."
  }
}

Scenario: Doctor Assistant

{
  "required_assistant": "doctor_assistant_name",
  "patient_data": {
    "patient_phone_number": "..."
  },
  "doctor_data": {
    "doctor_id": "...",
    "question": "Doctor's query..."
  }
}

Response:

{
  "status": true,
  "message": {
    "impressions": "...",
    "plans": "...",
    "citations": [...]
  }
}

Show Patient Preferences

POST /show_patient_preferences

Retrieves stored language and modality preferences.

Request Body:

{
  "phone": "string"
}

Response:

{
  "status": true,
  "message": "Success",
  "data": {
    "user_id": "PAT_233...",
    "modality": "text", 
    "language": "English"
  }
}

Get Analysis Summary

GET /analysis/summary/{patient_id}

Returns the AI summary of recent conversations.

Response:

{
  "summary": "Patient reported mild headache...",
  "risk_score": "low",
  "data_points": [
    {"type": "glucose", "value": "5.5", "timestamp": "..."}
  ]
}

EHR Backend

POST /api/patients

Create a new patient.

Headers: Authorization: Bearer <token>