WhatsApp Setup Guide
WhatsApp Setup Guide
Section titled “WhatsApp Setup Guide”Connect a clinic’s phone number to Meta Cloud API so the AI chatbot can receive and send messages.
Prerequisites
Section titled “Prerequisites”- A Meta Business Account (business.facebook.com)
- A phone number not currently registered on WhatsApp (can be a mobile number that receives SMS or voice calls)
- Admin access to the clinic’s ClinicFlow dashboard
Step 1: Create a Meta App
Section titled “Step 1: Create a Meta App”- Go to developers.facebook.com → My Apps → Create App
- Select Business as the app type
- Name the app (e.g., “ClinicFlow - Clínica X”)
- Link it to your Meta Business Account
Step 2: Add WhatsApp to the App
Section titled “Step 2: Add WhatsApp to the App”- In the App Dashboard → Add Products → WhatsApp → Set Up
- Under WhatsApp → Getting Started:
- Create or select a WhatsApp Business Account (WABA)
- Note the WABA ID (you’ll need it in Step 4)
- Get a temporary access token: WhatsApp → API Setup → Temporary access token
- This token expires in 24 hours — complete the setup before it expires
- For production, generate a permanent System User token (Meta Business Settings → System Users)
Step 3: Configure Webhook in Meta App
Section titled “Step 3: Configure Webhook in Meta App”- In your Meta App → WhatsApp → Configuration → Webhook
- Set Callback URL:
https://api.clinicflow.lat/webhooks/whatsapp - Set Verify Token: the value of your
WHATSAPP_WEBHOOK_VERIFY_TOKENenvironment variable - Click Verify and Save
- Subscribe to the
messagesfield
Step 4: Register the Number in ClinicFlow
Section titled “Step 4: Register the Number in ClinicFlow”- In the clinic dashboard → Configuración → WhatsApp
- Enter:
- WhatsApp Business Account ID: the WABA ID from Step 2
- Access Token: the temporary (or permanent) token from Step 2
- Click Conectar número
- Enter the phone number (E.164 format:
+503XXXXXXXX) - Choose OTP delivery method: SMS or Voice call
- Click Solicitar código OTP
Step 5: Verify OTP
Section titled “Step 5: Verify OTP”- The phone receives a 6-digit OTP from Meta/WhatsApp
- Enter the OTP in the dashboard
- Click Verificar
- Status should update to Activo ✓
If status shows Verificando (verifying), wait 1-2 minutes and refresh — the status auto-heals by polling Meta.
Step 6: Enable the Bot
Section titled “Step 6: Enable the Bot”- In Configuración → WhatsApp, toggle Bot habilitado to ON
- Test by sending a WhatsApp message to the clinic’s number
- The chatbot should respond with the welcome menu
Troubleshooting
Section titled “Troubleshooting”Status stuck on “Verificando”
Section titled “Status stuck on “Verificando””Meta’s number activation can take 1-5 minutes. The dashboard polls /api/whatsapp/status which self-heals verifying → active. If it’s been more than 10 minutes:
- Check that the OTP was entered correctly
- Try disconnecting and re-registering
- Verify the phone number format is correct E.164 (e.g.,
+50377654321)
Token Expired
Section titled “Token Expired”Temporary Meta tokens expire in 24 hours. If the chatbot stops working:
- Generate a new temporary token (or create a System User for a permanent token)
- Update in ClinicFlow: Configuración → WhatsApp → Actualizar token
For production, always use a System User token — these don’t expire.
Bot Not Responding
Section titled “Bot Not Responding”- Check
bot_enabled = truein clinic settings - Verify the patient is not
is_blocked = true - Check
human_handoveris not set on the chat session - Check the Meta App webhook subscription is active (
messagesfield subscribed) - Look for errors in Railway logs:
POST /webhooks/whatsapp
“Phone number already registered”
Section titled ““Phone number already registered””The phone number is already connected to a WhatsApp account. You must:
- Delete the number from its current WhatsApp account (via the WhatsApp app)
- Wait for the deletion to propagate (up to 24 hours)
- Then register through ClinicFlow
Webhook Verification Failed
Section titled “Webhook Verification Failed”Ensure WHATSAPP_WEBHOOK_VERIFY_TOKEN in your .env exactly matches what you entered in the Meta App webhook configuration.
System User Token (Production)
Section titled “System User Token (Production)”For production, use a System User token that never expires:
- Meta Business Settings → System Users → Add
- Create a system user with Employee role
- Add your WhatsApp app with Full Control
- Generate a token with permissions:
whatsapp_business_messaging,whatsapp_business_management - Copy the token → update in ClinicFlow Settings