A WhatsApp bot that simplifies appointment booking using templated replies through Twilio API. The bot integrates with a business API to register appointments seamlessly, eliminating the need for website visits or calls to reception. It stores customer information in a database for personalized interactions.
- Appointment Registration:
Automatically book appointments by sending customer data to the business API. - Customer Information Management:
Stores and retrieves user data, including names and phone numbers. - Dynamic State Handling:
Manages user states for seamless conversation flow, from greeting to appointment confirmation. - Templated Replies:
Utilizes Twilio's templated messages for a smooth user experience. - Public Exposure Using ngrok:
Exposes the local Flask app to the internet usingngrokfor seamless integration with Twilio Webhooks.
git clone https://github.com/yourusername/WhatsApp-Appointment-Bot.git
cd WhatsApp-Appointment-Botpip install Flask twiliopython Appointment_bot.pyDownload and install ngrok from https://ngrok.com/download.
Start ngrok with the following command:
ngrok http 5000Copy the public URL provided by ngrok (e.g., https://your-ngrok-url.ngrok.io).
Go to your Twilio Console and set the Webhook URL for incoming messages to:
https://your-ngrok-url.ngrok.io/webhook
account_sid = 'ENTER YOUR TWILIO ACCOUNT SID HERE'auth_token = 'ENTER YOUR TWILIO AUTH TOKEN HERE'- Replace template IDs in the
send_template_message()function with your Twilio template IDs.
api_url = f"{branch_apis[str(business_id)]}add_appointment/"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"SKED-API-KEY": "PUT YOUR API KEY HERE"
}
response = requests.post(api_url, data=form_data, headers=headers)ngrok http 5000def save_customer(phone, name):
conn = sqlite3.connect('salon.db')
cursor = conn.cursor()
cursor.execute("INSERT OR REPLACE INTO customers (phone, name) VALUES (?, ?)", (phone, name))
conn.commit()
conn.close()The goal is to offer a fully automated appointment booking service across multiple messaging platforms (e.g., WhatsApp, Telegram). This will provide users with a convenient and flexible system to manage appointments without needing to visit a website or call reception.
I'm a student working on this project and currently lack the resources to scale it. If you're interested in supporting or collaborating, please reach out to help bring this idea to life!

