Skip to content

Commit

Permalink
Initial code to send message on WhatsApp
Browse files Browse the repository at this point in the history
  • Loading branch information
zilurrane committed Sep 12, 2020
0 parents commit 84d882f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
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"]
10 changes: 10 additions & 0 deletions action.yml
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"
19 changes: 19 additions & 0 deletions whatsapp.py
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']
)

0 comments on commit 84d882f

Please sign in to comment.