Last active
February 25, 2018 19:00
-
-
Save marcesher/403d656ceb0de2d04091d16b4d736f4e to your computer and use it in GitHub Desktop.
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
region: us-east-1 | |
function_name: hello_twilio | |
handler: service.handler | |
role: lambda_execution_role | |
description: trying to use lambda to make twilio calls | |
# if access key and secret are left blank, boto will use the credentials | |
# defined in the [default] section of ~/.aws/credentials. | |
aws_access_key_id: | |
aws_secret_access_key: | |
# dist_directory: dist | |
timeout: 15 | |
memory_size: 128 |
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
export twilio_sid="your_sid" | |
export twilio_token="your_token" | |
export from_number="+your_twilio_number" | |
export to_number_single_click="+number-to-call-when-single-click" #eg +12135551212 | |
export to_number_double_click="+number-to-call-when-double-click" | |
export to_number_long_click="+number-to-call-when-long-click" |
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
{ | |
"clickType": "SINGLE" | |
} |
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
# pip install twilio==6.3.0 | |
from twilio.rest import Client | |
# you get the sid and token from your Twilio account | |
client = Client(sid, token) | |
call = client.api.account.calls \ | |
.create(to=call_to, | |
from_=call_from, | |
url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient") |
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
python-lambda==0.5.0 | |
twilio==6.3.0 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<Response> | |
<Say>Hello Monkey</Say> | |
<Play>http://demo.twilio.com/hellomonkey/monkey.mp3</Play> | |
</Response> |
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
import os | |
from twilio.rest import Client | |
def handler(event, context): | |
print "Event is " | |
print event | |
call_from = os.environ['from_number'] | |
sid = os.environ['twilio_sid'] | |
token = os.environ['twilio_token'] | |
click_type = event.get("clickType") | |
call_to = os.environ['to_number_single_click'] | |
if click_type == "DOUBLE": | |
call_to = os.environ['to_number_double_click'] | |
elif click_type == "LONG": | |
call_to = os.environ['to_number_long_click'] | |
print "Calling %s" % call_to | |
client = Client(sid, token) | |
call = client.api.account.calls \ | |
.create(to=call_to, | |
from_=call_from, | |
url="http://twimlets.com/message?Message%5B0%5D=Hello%20from%20twilio") |
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
import os | |
from twilio.rest import Client | |
def handler(event, context): | |
call_from = os.environ['from_number'] | |
sid = os.environ['twilio_sid'] | |
token = os.environ['twilio_token'] | |
call_to = os.environ['to_number_single_click'] | |
print "Calling %s" % call_to | |
client = Client(sid, token) | |
call = client.api.account.calls \ | |
.create(to=call_to, | |
from_=call_from, | |
url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient") |
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
call = client.api.account.calls\ | |
.create(to="+14085551234", # Any phone number | |
from_="+12125551234", # Must be a valid Twilio number | |
url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient") |
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
call = client.api.account.calls\ | |
.create(to="+14085551234", # Any phone number | |
from_="+12125551234", # Must be a valid Twilio number | |
url="http://twimlets.com/message?Message%5B0%5D=Hello%20from%20twilio") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment