Skip to content

dhavenstein/hackathon_whatsapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Small Twilio Demo for WhatsApp Hackathon

Setup

Create a .env file with the following variables:

MS_TWILIO_API_KEY_SID=<Yuval will share this with you>
MS_TWILIO_SECRET=<Yuval will share this with you>
MS_TWILIO_ACCOUNT_SID=<Yuval will share this with you>
MS_TWILIO_DEFAULT_SERVICE_SID=<Yuval will share this with you>

MS_WHATSAPP_NUMBER=<Yuval will share this with you>
PHONE_NUMBER=<Your phone number>

Install uv (https://github.com/astral-sh/uv)

curl -LsSf https://astral.sh/uv/install.sh | sh

Run

uv run main.py

You should see output similar to this, depending on what you write over WhatsApp:

uv run main.py
Initializing Twilio demo...
Getting my conversation... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--
Got a message from the user
Got a message from the user
Sending message to the user: Hey there, got your message: Ok, send '.' to end the conversation. Length of your last message: 2
Got a message from the user: 'Ok', and replied
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Got a message from the user
Sending message to the user: Hey there, got your message: Hey, send '.' to end the conversation. Length of your last message: 3
Got a message from the user: 'Hey', and replied
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Got a message from the user
Sending message to the user: Hey there, got your message: Whatup, send '.' to end the conversation. Length of your last message: 6
Got a message from the user: 'Whatup', and replied
Waiting for user message...
Waiting for user message...
Waiting for user message...
Waiting for user message...
Got a message from the user
Ending conversation...

Note: We must wait for the user to send a message first, before we can send a message to the user. This is because WhatsApp does not allow us to send a message first without using a valid WhatsApp template to prevent spam.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages