Skip to content

Instantly share code, notes, and snippets.

@geekyarthurs
Created February 21, 2021 18:21
Show Gist options
  • Save geekyarthurs/0a5b904f453497841cfcbe57425374c1 to your computer and use it in GitHub Desktop.
Save geekyarthurs/0a5b904f453497841cfcbe57425374c1 to your computer and use it in GitHub Desktop.
import logging
import json
import azure.functions as func
from twilio.rest import Client
def main(msg: func.ServiceBusMessage):
account_sid = '#'
auth_token = '#'
client = Client(account_sid, auth_token)
def construct_message(body):
return f"Your order for {body['item']} was succesful. You need to pay {body['price']}. Thank you!"
json_str = msg.get_body().decode('utf-8')
# json_str = "{}"
body = json.loads(json_str)
message = client.messages.create(
messaging_service_sid='MG3eed970714f552e0ef7e0bac6b59890c',
body=construct_message(body),
to=body.get("contact")
)
logging.log(msg=message.sid, level=50)
return message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment