whatsapp-bot / README.md
miftahulkhairim's picture
Update README.md
de0725f verified
metadata
title: WhatsApp Bot
emoji: πŸ’¬
colorFrom: green
colorTo: blue
sdk: docker
app_port: 7860
pinned: false
thumbnail: >-
  https://cdn-uploads.huggingface.co/production/uploads/69ef44f7daf9d56653d76e81/D9XBNpMMZAIZyMhg2nLS1.jpeg

πŸ’¬ WhatsApp Bot on Hugging Face

A WhatsApp chatbot powered by AI, deployed as a Docker Space on Hugging Face.

Architecture

WhatsApp Cloud API (Meta)
       β”‚
       β–Ό HTTPS webhooks
https://miftahulkhairim-whatsapp-bot.hf.space/webhook
       β”‚
       β–Ό
HF Docker Space (FastAPI, port 7860)
  β”œβ”€β”€ GET  /webhook  β†’ Meta webhook verification
  β”œβ”€β”€ POST /webhook  β†’ Receive message β†’ AI reply β†’ Send via WhatsApp API
  └── GET  /         β†’ Dashboard UI

Setup Guide

1. Meta Developer Portal Setup

  1. Go to developers.facebook.com β†’ Create App β†’ Choose Business type
  2. Add the WhatsApp product to your app
  3. In WhatsApp β†’ Getting Started, note your:
    • Phone Number ID
    • WhatsApp Business Account ID
    • Temporary Access Token (for testing)
  4. Go to WhatsApp β†’ Configuration β†’ Webhook:
    • Callback URL: https://miftahulkhairim-whatsapp-bot.hf.space/webhook
    • Verify Token: Choose any secret string (e.g., my_verify_token_2024)
    • Subscribe to: messages

2. HF Space Secrets

Go to Space Settings β†’ Repository Secrets and add:

Secret Name Value
WHATSAPP_VERIFY_TOKEN Your chosen verify token string
WHATSAPP_TOKEN Meta access token (from Developer Portal)
PHONE_NUMBER_ID Your WhatsApp Phone Number ID
HF_TOKEN Your HF token (for AI inference)

3. Deploy

The Space auto-builds and deploys when you push changes.

Features

  • πŸ€– AI-powered responses using Hugging Face Inference API
  • πŸ’¬ Handles text messages from WhatsApp
  • πŸ“Š Web dashboard showing bot status and recent messages
  • πŸ”’ Secure webhook verification
  • ⚑ Async message processing for fast responses

Notes

  • Free Spaces sleep after ~15 min of inactivity. Consider upgrading to paid hardware for always-on availability.
  • Access tokens from Meta expire. Use a System User permanent token for production.