twilio Flashcards
twilio: To set up call forwarding
put
http://twimlets.com/forward?PhoneNumber=%2B972537227817
into the Voice Request URL in the phone number’s settings
Note: %2B is the plus sign which comes before the full number.
twiml: When someone calls your twilio number
it send a request to twilio, who then sends a request with parameters to you, and based on the parameters you must respond to twilio with an xml object of what you want to do (e.g. say, redirect, play).
https://twilio.radicalskills.com/projects/talk-to-an-agent/2.html
twiml: To make a call forwarding system for paypercall you should essentially
have the request trigger a gathering of response if you want accept the call, and if you do, forward the pending call.
twiml: twilio.twiml.Response() is
an in memory xml object representation
twilio: To get a CSV of all the calls made
https://api.twilio.com/2010-04-01/Accounts/ACcb2f97bf9d187010ed5d5b6343ab8f4e/Calls.csv?PageSize=1000
enter Ac SID as Username and Auth Token as Password
twilio: The api endpoint for a list of the calls is
https://api.twilio.com/2010-04-01/Accounts/ACcb2f97bf9d187010ed5d5b6343ab8f4e/Calls
twilio: The From and FormattedFrom columns in the calls reports csv show
The caller ID, not the actual number
twilio: To make a link become a click to call, type
href=”tel:0327227817”
note: Plus sign is option, it literally dials what you wrote
twilio: To make a call get a spoken message and then get forwarded, type
pip install twilio
from twilio import twiml
from twilio.rest import TwilioRestClient
from django.http import HttpResponse
urls.py
url(r’^once_connected/’, views.once_connected_view, name=”once_connected”),
view.py def once_connected_view(request): response = twiml.Response() response.say("dial out to your sales team with the Dial verb", voice='alice') response.dial("972-53-722-7817") return HttpResponse(str(response))
and set the request url on twilios phone number preferences to http://www.exmaple.com/once_connected/ and GET REQUEST
Note: response.dial must be formated with only hyphens and must contain full area code.
twilio: To give the callee a Say before they are connected to the caller, you must
add an attribute to the Number noun within the Dial verb called url and pass is the URL of the twiml you want to execute on the callee
e.g.
with response.dial(attribute=”value”) as r:
r.number(“972-53-722-7817”, url=”http://…”, method=”GET”)
twilio: To add an attribute to a noun or verb, type
response.dial(attribute=”value”)
twilio: To make a nest noun inside a verb, type
with response.dial(attribute=”value”) as r:
r.number(“972-53-722-7817”, attribute=”value”)
twilio: Often times when there is an error it is because
I have sent a POST request to my server instead of a GET
twilio: To create a twilio app go to
account
dev tools
twiml app
twilio: To play audio for a caller, type
response.play(“http://demo.twilio.com/hellomonkey/monkey.mp3”)
twilio: To call through a browser
create application id
Go to domain using httpS
pass a permission token into the template
from twilio.util import TwilioCapability
capability = TwilioCapability(account_sid, auth_token)
capability.allow_client_outgoing(application_sid)
token = capability.generate()
render(…,{“token”:token}) (pass into render)
create twiml url to react to connection to twilio from the capability token
def twiml(request): response = twiml.Response() response.say("string") response.dial("972537227817", callerId="+18186503041") return HttpResponse(str(response)) # callerId mandatory
Add to template in head -script type="text/javascript" src="//static.twilio.com/libs/twiliojs/1.2/twilio.min.js">-/script> -script type="text/javascript"> Twilio.Device.setup("{{ token }}"); Twilio.Device.ready(function (device) { //... }); Twilio.Device.error(function (error) { //... }); Twilio.Device.connect(function (conn) { //... }); function call() { Twilio.Device.connect(); } function hangUp() { Twilio.Device.disconnect(function (conn) { $("#log").text("Call ended"); }); } -/script>
Note: The page that contains twilio must be rendered by a server.
twilio: The voice debugger url is
https://www.twilio.com/user/account/monitor/alerts
twilio: To instantiate a call in a script, type
from twilio.rest import TwilioRestClient
client = TwilioRestClient(‘ACcb2f97bf9d187010ed5d5b6343ab8f4e’, ‘8605322b42fc6848fce03e94465b4377’)
client.calls.create(to=”+972537227817”,
from_=”+18186503041”,
url=”http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient”)
twilio: when your browser initiates a Twilio Client connection to Twilio
a request is made to the Voice request url the app from the capability token you sent in, then Twilio uses the TwiML response from its request to direct what happens with the Client connection.
twilio: The dial verb in twiml must always
be accompanied by an attribute callerID=”+18186503041”
twilio: The single origin policy also
prohibits requests to other urls while in development
ssl: To make your site https
generate private key and csr (combined certificate)
openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr
answer the prompt:
Common name: www.yourdomain.com (must be subdomain specific)
State: Black if not applicable
Country: Two-letter ISO country code
Passphrase: Leave blank
Send the content of the CSR to a CA (Cerftying Authority)
CA will return a certification and save it as example.com.cert on pythonanywhere
CA will also return a certification chain (text file with various certs)
Prepend your certification to the certification chain text file and save it as example.com.combined.cert
if key is ~ Proc-Type: 4,ENCRYPTED type
openssl rsa -in server.key.encrypted -out server.key
Tell pythonanywhere through feedback where the combined.cert file and key are