diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..30d05a2 --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..1004730 --- /dev/null +++ b/action.yml @@ -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" diff --git a/whatsapp.py b/whatsapp.py new file mode 100644 index 0000000..155818d --- /dev/null +++ b/whatsapp.py @@ -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'] + )