Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.akapulu.com/llms.txt

Use this file to discover all available pages before exploring further.

The avatar will act as a friendly medical screening assistant that guides the patient through the screening process, with access to a vision tool to view the patient’s symptoms on camera if requested, as well as a RAG tool for clinic details and an appointment booking tool to schedule the appointment.

Tags

transition-function, vision-function, rag-function, endpoint-function, endpoint-simple-transition, end-after-bot-response, stt-keywords, runtime-vars-in-instructions, runtime-vars-in-http-endpoints, llm-template-variables, secret-variables, role-instruction

What this example shows

  • Scenario creation and node configuration
  • Endpoint usage for HTTP calls
  • Knowledge base integration for RAG-driven answers
  • Runtime variables for patient_id, today
  • Connecting the scenario to the Web SDK examples

Node flow

The avatar’s role instruction:
“You are a friendly and professional medical screening assistant…”
The scenario is structured around the following node sequence:
  • intro
    • “Greet the patient warmly and introduce yourself as a medical screening assistant…”
    • Uses transition tools.
  • data_intake
    • “Collect the patient’s basic information…”
    • Uses transition, vision tools.
  • appointment_booking
    • “Help the patient schedule an appointment…”
    • Uses http tools.
  • qa
    • “Answer the patient’s questions about the screening process, our clinic, or anything else they want to know…”
    • Uses transition, rag tools.
  • end
    • “Thank the patient for completing the screening…”
    • Ends the conversation after the assistant responds.

Secrets

Create these secrets in the Akapulu secrets tab:
  • Create secret
    • Name: webhook_token
    • Example value: webhook_secret_123

Endpoints

Patient Intake Get Availability

Use your hosted endpoint URL below.
  • Setup tab
    • Name: Patient Intake Get Availability
    • URL: https://<YOUR_HOSTED_ENDPOINT_DOMAIN>/get-availability
    • Method: POST
  • Headers/Body tab
    • headers:
      {
        "Content-Type": "application/json",
        "X-Patient-ID": "{{runtime.patient_id}}",
        "Authorization": "Bearer {{secret.webhook_token}}"
      }
      
    • body:
      {
        "preferred_date": "{{llm.preferred_date:Preferred date or start of range in YYYY-MM-DD}}",
        "appointment_type": "{{llm.appointment_type:Type like follow_up or new_consult}}",
        "patient_id": "{{runtime.patient_id}}"
      }
      
  • Local server behavior
    • Returns a list of available appointment slots for the requested preferred date and appointment type.

Patient Intake Book Appointment

Use your hosted endpoint URL below.
  • Setup tab
    • Name: Patient Intake Book Appointment
    • URL: https://<YOUR_HOSTED_ENDPOINT_DOMAIN>/book-appointment
    • Method: POST
  • Headers/Body tab
    • headers:
      {
        "Content-Type": "application/json",
        "X-Patient-ID": "{{runtime.patient_id}}",
        "Authorization": "Bearer {{secret.webhook_token}}"
      }
      
    • body:
      {
        "date": "{{llm.date:Appointment date in YYYY-MM-DD}}",
        "time": "{{llm.time:Appointment time in HH:MM 24-hour}}",
        "appointment_type": "{{llm.appointment_type:Type like follow_up or new_consult}}",
        "patient_id": "{{runtime.patient_id}}",
        "source": "patient_intake_screening"
      }
      
  • Local server behavior
    • Accepts appointment booking details, logs request metadata, and returns a generated appointment confirmation id.

Knowledge bases

Healthcare Intake Demo Knowledge Base

  • Knowledge base details
    • Name: Healthcare Intake Demo Knowledge Base
    • Description: Reference information for the Healthcare Intake & Scheduling demo scenario, including clinic policies, appointment details, and patient-facing FAQ content.
  • Document details
    • Name: Clinic Details
    • Description: Clinic operations, hours, policies, and scheduling information used by the demo assistant for patient Q&A.
  • Upload this file

Node JSON to paste

Replace these placeholders:
  • <YOUR_GET_AVAILABILITY_ENDPOINT_ID>
  • <YOUR_BOOK_APPOINTMENT_ENDPOINT_ID>
  • <YOUR_ABOUT_OUR_CLINIC_KNOWLEDGE_BASE_ID>
{
  "role_instruction": "You are a friendly and professional medical screening assistant.\n\nYour responses will be converted to audio, so keep them concise and avoid special characters.\n\nSpeak clearly and warmly to help patients feel comfortable.\n\nDo not start sentences with short bursts like sure! or absolutely! since short bursts lead to choppy audio.",
  "nodes": {
    "intro": {
      "functions": [
        {
          "name": "transition_to_data_intake",
          "type": "transition",
          "description": "Use this function to transition to the data_intake phase after they have given consent to proceed.",
          "transition_to": "data_intake"
        }
      ],
      "task_instruction": "Greet the patient warmly and introduce yourself as a medical screening assistant. Explain that you'll help them with a brief screening questionnaire.\n\nAfter they have given consent to move to next stage, use the transition tool to move forward to the data intake phase."
    },
    "data_intake": {
      "functions": [
        {
          "name": "transition_to_appointment_booking",
          "type": "transition",
          "description": "Transition to the appointment booking phase.",
          "transition_to": "appointment_booking"
        },
        {
          "name": "VIEW_CAMERA",
          "type": "vision",
          "description": "Use this tool when the user asks you to look at the screen"
        }
      ],
      "task_instruction": "Collect the patient's basic information. Ask for their full name, age, primary reason for visit, and any current symptoms or concerns. Be conversational and ask one question at a time.\n\nIf the patient indicates they are showing something on camera (for example: this part of my hand hurts, can you see this rash, what does this look like), call the vision tool.\n\nWhen you've gathered enough information, use the transition tool to move to appointment booking.\n\nIf the patient asks questions, politely redirect them to answer the screening questions first, and mention they can ask questions later in the Q&A phase."
    },
    "appointment_booking": {
      "functions": [
        {
          "name": "get_availability",
          "type": "http",
          "description": "Fetch available appointment slots before booking. Call this after the patient gives a preferred date and appointment type so you can offer real open slots.",
          "endpoint_id": "<YOUR_GET_AVAILABILITY_ENDPOINT_ID>"
        },
        {
          "name": "book_appointment",
          "type": "http",
          "description": "Call this tool to book the appointment after the patient has confirmed one of the available slots returned by get_availability.",
          "endpoint_id": "<YOUR_BOOK_APPOINTMENT_ENDPOINT_ID>",
          "transition_to": "qa"
        }
      ],
      "task_instruction": "Help the patient schedule an appointment. Ask about their preferred date and whether they prefer in-person or virtual consultation. \n\nOnce you have a preferred date and appointment type, call the get_availability tool to fetch real open slots and offer those to the patient.\n\nAfter the patient picks a slot, use the book_appointment tool to confirm the booking.\n\nNote - today is {{runtime.today}}"
    },
    "qa": {
      "functions": [
        {
          "name": "transition_to_end_screening",
          "type": "transition",
          "description": "Transition to the end of the screening session.",
          "transition_to": "end"
        },
        {
          "name": "about_our_clinic",
          "type": "rag",
          "knowledge_base_id": "<YOUR_ABOUT_OUR_CLINIC_KNOWLEDGE_BASE_ID>",
          "description": "a RAG tool with information about our clinic"
        }
      ],
      "task_instruction": "Answer the patient's questions about the screening process, our clinic, or anything else they want to know. Be helpful, empathetic, and professional. If you don't know something, suggest they discuss it with their doctor during the appointment. Keep responses concise since they'll be converted to audio.\n\nUse the transition tool to end the screening session when the patient is ready to conclude.\n\nIf they have a question about our clinic use the about_our_clinic rag tool"
    },
    "end": {
      "task_instruction": "Thank the patient for completing the screening. Provide a brief summary of next steps (e.g., 'We'll review your information and confirm your appointment details. A member of our team will contact you soon.').\n\nKeep it brief and friendly, then end the conversation.",
      "end_after_bot_response": true
    }
  },
  "initial_node": "intro"
}

Use in UI

After your scenario is saved, integrate it in your own application using the Akapulu Web SDK. Related docs pages: In the payload to the connectConversation method, pass scenario_id, avatar_id, and runtime variables required by this scenario (patient_id, today), for example:
const runtimeVars = {
  patient_id: "patient_001",
  today: new Date().toISOString().slice(0, 10),
};

const patientName = "James Bradford";

const sttKeywords = [patientName];

const connectPayload = {
  // Replace with your scenario id
  scenario_id: "<scenario id here>",

  // Catalog avatar id
  avatar_id: "f77de1e5-6ce3-448c-8cff-a8cc3c8a50bf",

  // Patient name as speech recognition keyword
  stt_keywords: sttKeywords,

  // Runtime variables
  runtime_vars: runtimeVars,

  // Record conversation
  record_conversation: true,
};

return await akapulu.connectConversation(connectPayload);

View on GitHub