Online Clinic Queue Tutorial via WhatsApp: Complete Integration Guide
T
Kembali ke Blog

Online Clinic Queue Tutorial via WhatsApp: Complete Integration Guide

Tutorial
Tim Pilar Inovasi 21 Jun 2026 13 min baca 2,887 kata 199
Learn how to build an online clinic queue system integrated with WhatsApp. This guide covers fundamental concepts, technical implementation, code examples, and best practices to improve operational efficiency and patient experience.

Opening a clinic in today's digital era means facing patients' increasingly high expectations for efficiency and ease of access to services. One of the biggest challenges often faced is queue management. Long manual queues not only reduce patient satisfaction but also burden administrative staff, causing bottlenecks, and potentially creating undesirable crowding, especially in the context of health standards. A study from The Beryl Institute shows that a positive patient experience directly correlates with loyalty and recommendations. In this context, an online queue system integrated with WhatsApp is no longer a luxury, but a fundamental need to improve operational efficiency and provide a superior patient experience. This article will guide you comprehensively, step by step, in designing and implementing a clinic online queue system integrated with WhatsApp, from basic concepts to code examples that you can apply immediately. We will discuss the technical architecture, platform selection, data handling, and best practices to ensure this solution runs optimally in your clinic environment.

Basic Concepts of Online Queues and WhatsApp Integration

An online queue system is essentially a digital platform that allows patients to register and get a queue number without having to be physically present at the location, reducing waiting time and clinic crowding. Integration with WhatsApp, as the most popular messaging application in Indonesia with more than 100 million users, is the key to achieving maximum reach and ease of access. The core concept is to utilize the WhatsApp Business API for automated two-way communication between patients and your clinic system. This includes sending queue notifications, schedule confirmations, reminders, and the ability for patients to cancel or change schedules through simple chat interactions.

The basic architecture for this system generally involves three main components: first, your existing Clinic Management Information System (Clinic MIS), which serves as the data source for doctor schedules, slot availability, and patient data. Second, the Queue Application Backend, which will handle business logic, the queue database, and interact with the Clinic MIS and the WhatsApp Business API. Third, the WhatsApp Business API itself, which acts as the communication bridge. When a patient registers via WhatsApp, the backend will process the request, allocate a queue number, and store the data. Then, a notification will be sent back to the patient via WhatsApp.

For example, a patient can send the message "Register Queue" to the clinic's WhatsApp number. The system will respond with a choice of department/doctor and date. After the patient chooses, the system will confirm the queue number and estimated waiting time. This significantly reduces the receptionist's workload and increases transparency for patients. According to data from the Ministry of Health, administrative efficiency can increase by up to 30% with the digitalization of the registration process. This implementation also supports the SatuSehat initiative, where patient data and health services can be better integrated in the future.

The selection of a WhatsApp Business API provider (BSP) is also crucial. Some popular BSPs in Indonesia include Qiscus, WATI, or Barantum, which offer adequate SDKs and documentation for integration. It is important to understand the per-message pricing model and the features offered by each BSP. Make sure the chosen BSP supports the WhatsApp message template feature (HSM – Highly Structured Message) for important notifications, as well as webhooks to receive incoming messages from patients in real-time. With careful planning, this system not only manages queues but also becomes an effective and personal main communication channel with your patients.

Technical Implementation Details

Implementing an online queue system with WhatsApp integration requires several careful technical stages. First, prepare the backend infrastructure. We recommend using Laravel version 11.x as the PHP framework for the queue application backend because of its ease of development, rich ecosystem, and powerful ORM (Eloquent) features. For the database, PostgreSQL version 16 is an excellent choice because of its scalability, reliability, and support for JSONB features that are useful for storing semi-structured data. The server environment can use Ubuntu Server 22.04 LTS with PHP 8.3 and Nginx.

Integration with your Clinic MIS is a crucial step. If your Clinic MIS has an API (for example, a RESTful API), you can consume it directly from the Laravel application. Make sure the Clinic MIS API provides endpoints to: (1) Get the list of doctors and schedules, (2) Get queue slot availability, (3) Register new patients, and (4) Update queue status. If the Clinic MIS does not yet have an API, you need to create an integration layer (middleware) that reads from or writes directly to the Clinic MIS database (with great care and permission) or exposes an API from your Clinic MIS. In the context of SatuSehat or FHIR integration, make sure the relevant patient and service data are also prepared for the FHIR R4 payload, for example using HAPI FHIR 6.8 as a library for parsing or validation if needed, although for this simple queue it may not be immediately required.

The next step is integration with the WhatsApp Business API. After choosing a BSP (for example, Qiscus), you will get API credentials (API Key, Secret, Endpoint URL). Your Laravel application will communicate with this API. To receive incoming messages from patients, you need to configure a Webhook on your BSP dashboard, which will point to a specific endpoint in your Laravel application (for example, /api/whatsapp/webhook). Every time a patient sends a message, the BSP will send a JSON payload to this endpoint. You then process that message, extract the relevant information (phone number, message content), and run the business logic to respond.

Managing the patient conversation state is also important. You can store this state in a PostgreSQL database, for example, a whatsapp_sessions table that records the conversation ID, patient number, and the last step in the queue flow (e.g., "waiting for polyclinic selection", "waiting for date selection", "queue confirmation"). To send outgoing messages, you will use an SDK or HTTP client (such as Guzzle in Laravel) to call the BSP's message-sending endpoint. Be sure to use message templates (HSM) that have been approved by Facebook/Meta for important notifications such as queue confirmations or reminders, because these have a higher delivery rate and lower cost compared to free-form messages.

Example Implementation Code

This section will present an example of PHP (Laravel) code that shows the basic way to receive a webhook from the WhatsApp Business API and send a reply. Assume you have installed Laravel 11.x and configured a PostgreSQL 16 database. First, we will create a controller to handle the WhatsApp webhook.

<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;use Illuminate\Support\Facades\Http;use Illuminate\Support\Facades\Log;class WhatsappWebhookController extends Controller{    protected $whatsappApiUrl;    protected $whatsappApiKey;    public function __construct()    {        $this->whatsappApiUrl = env('WHATSAPP_API_URL'); // e.g., https://api.qiscus.com/v2/bot/        $this->whatsappApiKey = env('WHATSAPP_API_KEY'); // your BSP API Key    }    public function handleWebhook(Request $request)    {        Log::info('WhatsApp Webhook Received', $request->all());        $messages = $request->input('messages'); // Structure may vary by BSP        if (empty($messages)) {            return response()->json(['status' => 'No messages received'], 200);        }        foreach ($messages as $message) {            $from = $message['from']; // Sender's phone number            $text = strtolower($message['text']['body'] ?? ''); // Message content            Log::info("Message from {$from}: {$text}");            // Basic keyword response            if ($text === 'daftar antrian') {                $this->sendWhatsappMessage($from, 'Selamat datang di layanan antrian online kami. Silakan pilih poli yang Anda inginkan: Poli Umum, Poli Gigi, Poli Anak.');            } elseif ($text === 'poli umum') {                $this->sendWhatsappMessage($from, 'Anda memilih Poli Umum. Silakan kirim tanggal antrian (format YYYY-MM-DD), contoh: 2024-07-25');            } else {                $this->sendWhatsappMessage($from, 'Maaf, saya tidak mengerti. Ketik "Daftar Antrian" untuk memulai.');            }        }        return response()->json(['status' => 'Webhook processed'], 200);    }    protected function sendWhatsappMessage(string $to, string $message)    {        try {            $response = Http::withHeaders([                'Authorization' => 'Bearer ' . $this->whatsappApiKey,                'Content-Type' => 'application/json',            ])->post("{$this->whatsappApiUrl}/send_message", [ // Adjust endpoint based on BSP                'to' => $to,                'type' => 'text',                'text' => ['body' => $message],            ]);            Log::info('WhatsApp Message Sent', ['to' => $to, 'message' => $message, 'response' => $response->json()]);        } catch (\Exception $e) {            Log::error('Failed to send WhatsApp message', ['error' => $e->getMessage()]);        }    }}

The code above is a basic example for receiving messages from a webhook and providing a simple reply. The variables $whatsappApiUrl and $whatsappApiKey must be defined in your .env file. The webhook payload structure can vary between BSPs, so you need to adjust it based on the documentation of the BSP you are using. The sendWhatsappMessage function shows the basic way to send a text message. For template messages (HSM), the payload structure will be different.

Next, we need to define a route for this webhook in routes/api.php:

<?phpuse Illuminate\Http\Request;use Illuminate\Support\Facades\Route;use App\Http\Controllers\WhatsappWebhookController;Route::post('/whatsapp/webhook', [WhatsappWebhookController::class, 'handleWebhook']);

After the route is defined, you must configure this webhook URL in your BSP dashboard. For example, if your application is accessed at https://klinik-anda.com, then the webhook URL that needs to be configured is https://klinik-anda.com/api/whatsapp/webhook. This code is the foundation for building more complex conversation logic, including input validation, interaction with the Clinic SIM database to check availability, and storing queue data in your PostgreSQL database. Be sure to add strong input validation and comprehensive error handling for every interaction with external APIs.

Example Payload and Error Handling

Understanding the structure of the payload sent by the WhatsApp Business API and how to handle errors is key to a robust system. Here is an example of a typical JSON payload sent by the BSP to your webhook endpoint when a patient sends a text message. This structure may differ slightly between BSPs, but the essence is similar:

{  "object": "whatsapp_business_account",  "entry": [    {      "id": "123456789012345",      "changes": [        {          "value": {            "messaging_product": "whatsapp",            "metadata": {              "display_phone_number": "62812XXXXXX",              "phone_number_id": "987654321098765"            },            "contacts": [              {                "profile": {                  "name": "Budi Santoso"                },                "wa_id": "6281212345678"              }            ],            "messages": [              {                "from": "6281212345678",                "id": "wamid.xxxxxxxxxxxxxxxxxxxxxxxxxxxx",                "timestamp": "1678886400",                "text": {                  "body": "Daftar Antrian"                },                "type": "text"              }            ]          },          "field": "messages"        }      ]    }  ]}

From the payload above, you can extract the sender's number (entry[0].changes[0].value.messages[0].from) and the message content (entry[0].changes[0].value.messages[0].text.body). Make sure to always validate the existence of these keys before accessing them to avoid errors. For example, if messages is empty or text is missing, your code should be able to handle it gracefully.

Example Error Message and Handling:

One common error that may occur is failure to send a message via the WhatsApp Business API. For example, if you try to send a template message without approval, or send a message to an invalid number, the API will return an error. An example error response from the BSP might look like this:

{  "error": {    "message": "Template message not approved or recipient is not opted in.",    "type": "OAuthException",    "code": 131051,    "fbtrace_id": "xxxxxxxxxx"  }}

How to Handle:

In your PHP code, you should always wrap external API calls in a try-catch block. When receiving an error response, log the error details carefully (as shown in Log::error in Section 3). For errors like the above (code 131051), this indicates that the message template used has not been approved or the recipient has not opted in. The solution is: (1) Ensure your message template has been approved by Meta, (2) Ensure the patient has given consent (opt-in) to receive messages from your clinic, which can be done through initial interaction on WhatsApp or a registration form. For network errors or timeouts, you can implement a retry mechanism with exponential backoff. Always monitor your application logs to detect and respond to errors quickly, ensuring the queue system runs smoothly and patient communication is not interrupted.

Best Practices

  1. Choose the Right BSP (Business Solution Provider): Conduct in-depth research on the various BSPs available in Indonesia. Consider factors such as price per message, features offered (e.g., template support, interactive features, analytics), quality of technical support, and SLA (Service Level Agreement). Ensure the chosen BSP has a good track record and fits the scale needs of your clinic.
  2. Prioritize Patient Data Security (PHI): Patient health data is sensitive information. Ensure all communication and data storage comply with relevant security standards, such as ISO 27001 and personal data protection regulations (e.g., PDP Law in Indonesia). Use HTTPS/SSL connections for all API communications and encrypt sensitive data when stored in the database.
  3. Design an Intuitive Conversation Flow: Create a WhatsApp conversation flow that is clear, concise, and easy to understand for patients from various backgrounds. Use buttons or selection lists when possible to minimize free text input and reduce the potential for errors. Test this flow extensively with various user scenarios.
  4. Optimize the Use of Message Templates (HSM): Use approved WhatsApp message templates for all important notifications such as queue confirmations, schedule reminders, and change information. This is not only more cost-effective but also has a higher delivery rate and avoids spam blocking. Avoid sending promotional messages without explicit consent.
  5. Implement Fallback and Error Handling Mechanisms: Prepare backup mechanisms in case of failure in the WhatsApp system or Clinic SIM. For example, if a WhatsApp message fails to send, the system can try sending an SMS or email as an alternative. Implement comprehensive logging and monitoring systems to detect and respond to errors proactively.
  6. Two-Way Integration with Clinic SIM: Ensure your online queue system not only retrieves data from the Clinic SIM but can also send back important information, such as updated queue status, patient arrival confirmation, or cancellation. This maintains data consistency and provides an accurate operational picture to clinic staff.
  7. Conduct Scale and Stress Testing: Before fully launching the system, perform performance testing to ensure the system can handle high queue volumes, especially during peak hours. Also test the system's resilience to various scenarios, including network failures or spikes in demand, to guarantee stability and reliability.
  8. Provide a Clear Opt-out Option: In accordance with WhatsApp Business API policies and data protection regulations, patients must always have the option to stop receiving messages from your clinic. Provide clear instructions (e.g., "Type STOP to stop") and ensure your system can process these opt-out requests immediately.

FAQ

  1. Do I need the WhatsApp Business API or is the regular WhatsApp Business App enough?

    For an integrated and automated online queue system, you MUST use the WhatsApp Business API. The regular WhatsApp Business App is only suitable for manual one-on-one communication and does not have API capabilities for system integration, automated bulk messaging, or webhook handling. The WhatsApp Business API allows your clinic to have a "bot" that can interact intelligently with patients.

  2. How much does it cost to implement this?

    Costs vary depending on several factors: BSP service fees (usually per message or per conversation), development costs (if using an external developer), and server infrastructure costs. BSPs like Qiscus or WATI have different pricing structures. An initial estimate could start from a few million rupiah for initial development, plus monthly operational costs for the WhatsApp Business API that can range from hundreds of thousands to millions of rupiah depending on message volume.

  3. How do I ensure patient data security in this system?

    Patient data security is the top priority. Ensure your application server is protected with a firewall, uses encrypted connections (HTTPS/SSL), and your database is encrypted. Limit access to sensitive data to authorized personnel only. Additionally, ensure the BSP you choose also complies with strict data security standards and has relevant certifications, and comply with the Personal Data Protection Law applicable in Indonesia.

  4. Can this system be integrated with a larger SIMRS (Hospital Management Information System)?

    Yes, of course. The architecture described in this article is designed to be modular and able to integrate with SIMRS. The key is that your SIMRS has adequate APIs to exchange data (schedules, patients, queues, etc.). If your SIMRS supports FHIR R4 or HL7 v2.5.1 standards, integration will be easier and more standardized. Nugroho Setiawan has specific experience in bridging integration for BPJS/SatuSehat/FHIR, so this aspect can be well accommodated.

  5. What if patients do not have WhatsApp or are not used to using it?

    Although WhatsApp is very popular, it is important to still provide alternatives. You can offer options for queue registration via the clinic website, phone, or direct registration on-site. This online queue system via WhatsApp is a complement to improve efficiency, not an absolute replacement. Consider providing brief education to patients on how to use this system.

  6. How to handle changes or cancellations of queues by patients via WhatsApp?

    You need to extend your bot's conversation flow to handle this scenario. For example, patients can send "Cancel Queue" or "Change Schedule". The system will request the queue number or patient identity, then validate the request with the data in the Clinic SIM. After validation, the system can update the queue status and send a confirmation to the patient. This requires more complex business logic in your backend.

Adopting an online queue system integrated with WhatsApp is not just about following technological trends, but a strategic investment for the future of your healthcare services. With increased operational efficiency, better patient satisfaction, and more personalized communication, your clinic will be ready to face challenges in the digital era. The process described in this tutorial may seem complex, but with a structured approach and the right tools, you can build a robust and effective solution. If you need further assistance in designing, developing, or implementing a Clinic SIM solution, bridging integration with BPJS/SatuSehat/FHIR, or an online queue system tailored to your clinic's specific needs, do not hesitate to contact the Nugroho Setiawan team. We are ready to be your technology partner to realize a digital transformation with real impact.

Terakhir diperbarui 17 Oct 2026

Komentar

Komentar ditinjau sebelum tampil.

Belum ada komentar. Jadilah yang pertama!