Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:11
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Zillabyte component that uses Twilio to send an SMS to a subscriber about the local weather forecast
import zillabyte
from import TwilioRestClient
def send_text(controller, tup):
# Register twilio client
twilio_client = TwilioRestClient(tup["twilio_sid"], tup["twilio_auth"])
# Send message to recipient and wait 1 second (twilio SMS rate limit)
text_body = "It is going to be " + tup['condition'] + " in " + tup['city'] + " tomorrow!"
twilio_client.messages.create(to=tup["to"], from= tup["from"], body= text_body)
# Emit the recipient back to the stream...
controller.emit({"to" : text_to})
component = zillabyte.component(name="twilio_weather_text")
stream = component.inputs(
name = "input_stream",\
fields = [{"twilio_sid" : "string"}, {"twilio_auth" : "string"},\
{"from" : "string"}, {"to" : "string"}, {"city" : "string"},\
{"condition" : "string"}]\
stream = stream.each(send_text)
stream.outputs(name = "output_stream", fields=[{"to" : "string"}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment