-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial code to send message on WhatsApp
- Loading branch information
0 parents
commit 84d882f
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM python:3.7-slim | ||
ADD whatsapp.py /whatsapp.py | ||
RUN pip install --target=/app requests | ||
RUN pip install twilio | ||
RUN chmod +x /whatsapp.py | ||
CMD ["python", "/whatsapp.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "Message to Whatsapp" | ||
description: "Send message to WhatsApp number via Twillio" | ||
author: "Zilu Rane" | ||
branding: | ||
icon: message-circle | ||
color: green | ||
|
||
runs: | ||
using: "docker" | ||
image: "Dockerfile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
from twilio.rest import Client | ||
|
||
account_sid = os.environ['account_sid'] | ||
auth_token = os.environ['auth_token'] | ||
from_number = os.environ['from_number'] | ||
to_number = os.environ['to_number'] | ||
message = os.environ['message'] | ||
|
||
if from_number is None: | ||
from_number = '+14155238886' | ||
|
||
client = Client(account_sid, auth_token) | ||
|
||
message = client.messages.create( | ||
body=message, | ||
from_='whatsapp:'+from_number, | ||
to='whatsapp:'+os.environ['to_number'] | ||
) |