本文整理汇总了Python中tropo.Tropo.call方法的典型用法代码示例。如果您正苦于以下问题:Python Tropo.call方法的具体用法?Python Tropo.call怎么用?Python Tropo.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tropo.Tropo
的用法示例。
在下文中一共展示了Tropo.call方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tropo
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def tropo():
"""
Receive a JSON POST from the Tropo WebAPI
@see: https://www.tropo.com/docs/webapi/newhowitworks.htm
"""
# Stored in modules/tropo.py
from tropo import Tropo, Session
try:
s = Session(request.body.read())
t = Tropo()
# This is their service contacting us, so parse their request
try:
row_id = s.parameters["row_id"]
# This is an Outbound message which we've requested Tropo to send for us
table = s3db.msg_tropo_scratch
query = (table.row_id == row_id)
row = db(query).select().first()
# Send the message
#t.message(say_obj={"say":{"value":row.message}},to=row.recipient,network=row.network)
t.call(to=row.recipient, network=row.network)
t.say(row.message)
# Update status to sent in Outbox
outbox = s3db.msg_outbox
db(outbox.id == row.row_id).update(status=2)
# Set message log to actioned
log = s3db.msg_log
db(log.id == row.message_id).update(actioned=True)
# Clear the Scratchpad
db(query).delete()
return t.RenderJson()
except:
# This is an Inbound message
try:
message = s.initialText
# This is an SMS/IM
# Place it in the InBox
uuid = s.id
recipient = s.to["id"]
try:
fromaddress = s.fromaddress["id"]
except:
# SyntaxError: s.from => invalid syntax (why!?)
fromaddress = ""
s3db.msg_log.insert(uuid=uuid, fromaddress=fromaddress,
recipient=recipient, message=message,
inbound=True)
# Send the message to the parser
reply = msg.parse_message(message)
t.say([reply])
return t.RenderJson()
except:
# This is a Voice call
# - we can't handle these yet
raise HTTP(501)
except:
# GET request or some random POST
pass
示例2: sms_in
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def sms_in(request):
"""
Handles tropo messaging requests
"""
if request.method == "POST":
data = json.loads(request.body)
session = data["session"]
# Handle when Tropo posts to us to send an SMS
if "parameters" in session:
params = session["parameters"]
if ("_send_sms" in params) and ("numberToDial" in params) and ("msg" in params):
numberToDial = params["numberToDial"]
msg = params["msg"]
t = Tropo()
t.call(to = numberToDial, network = "SMS")
t.say(msg)
return HttpResponse(t.RenderJson())
# Handle incoming SMS
phone_number = None
text = None
if "from" in session:
phone_number = session["from"]["id"]
if "initialText" in session:
text = session["initialText"]
if phone_number is not None and len(phone_number) > 1:
if phone_number[0] == "+":
phone_number = phone_number[1:]
incoming_sms(phone_number, text, SQLTropoBackend.get_api_id())
t = Tropo()
t.hangup()
return HttpResponse(t.RenderJson())
else:
return HttpResponseBadRequest("Bad Request")
示例3: tropo_view
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def tropo_view(request):
if request.method == "POST":
data = json.loads(request.raw_post_data)
session = data["session"]
if "parameters" in session:
params = session["parameters"]
if ("_send_sms" in params) and ("numberToDial" in params) and ("msg" in params):
numberToDial = params["numberToDial"]
msg = params["msg"]
t = Tropo()
t.call(to = numberToDial, network = "SMS")
t.say(msg)
log("OUT", "TEXT", numberToDial, "TROPO", request.raw_post_data, msg)
return HttpResponse(t.RenderJson())
if "from" in session:
caller_id = session["from"]["id"]
channel = session["from"]["channel"]
msg = None
if "initialText" in session:
msg = session["initialText"]
log("IN", channel, caller_id, "TROPO", request.raw_post_data, msg)
if channel == "VOICE":
send_sms_tropo(caller_id, "Callback received.")
t = Tropo()
t.hangup()
return HttpResponse(t.RenderJson())
else:
return HttpResponseBadRequest()
示例4: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
t.call("+xxx")
t.record(name = "recording", timeout = 10, maxSilence = 7, maxTime = 60, choices = {"terminator": "#"}, transcription = {"id":"1234", "url":"mailto:[email protected]", "language":"de_DE"}, say = {"value":"Willkommen zur Abfage! Sag uns bitte, wie es dir geht!"}, url = "http://www.example.com/recordings.py", voice =" Katrin")
return t.RenderJson()
示例5: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
s = Session(request.body)
t = Tropo()
t.call(to=' ' + TO_NUMBER, _from=' ' + FROM_NUMBER, label='xiangwyujianghu', voice='Tian-tian', callbackUrl='http://192.168.26.88:8080/FileUpload/receiveJson', promptLogSecurity='suppress')
t.say('This is your mother. Did you brush your teeth today?')
json = t.RenderJson()
print json
return json
示例6: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
t.call(to="+17326820887", network = "SMS")
t.say("Tag, you're it!")
return t.RenderJson()
示例7: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
t.call("sip:[email protected]:5678")
t.say("tropo status")
t.wait(27222, allowSignals = 'dfghjm')
t.say("today is Friday 2017-06-02")
return t.RenderJson()
示例8: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
s = Session(request.body)
t = Tropo()
t.call(to='tel:+' + TO_NUMBER, _from='tel:+' + FROM_NUMBER)
t.say('This is your mother. Did you brush your teeth today?')
json = t.RenderJson()
print(json)
return json
示例9: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
#s = Session(request.body)
t = Tropo()
t.call(to=' ' + TO_NUMBER, _from=' ' + FROM_NUMBER, label='xiangwyujianghu', network = 'MMS')
mediaa = ['http://www.gstatic.com/webp/gallery/1.jpg', 'macbook eclipse', 'http://artifacts.voxeolabs.net.s3.amazonaws.com/test/test.png', 1234567890, '0987654321', 'https://www.travelchinaguide.com/images/photogallery/2012/beijing-tiananmen-tower.jpg']
t.say('This is your mother. Did you brush your teeth today?', media = mediaa)
json = t.RenderJson()
print json
return json
示例10: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
t.call(to = "[email protected]", _from = "[email protected]", channel = "TEXT", network = "JABBER")
t.ask(choices = "yes(yes,y,1), no(no,n,2)", timeout=60, name="reminder", say = "Hey, did you remember to take your pills?")
t.on(event = "continue", next ="verify_yes")
t.on(event = "incomplete", next ="verify_no")
json = t.RenderJson()
print json
return HttpResponse(json)
示例11: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
# s = Session(request.get_json(force=True))
sys.stderr.write(str(request.body) + "\n")
s = Session(request.body)
message = s.initialText
# print("Initial Text: " + initialText)
# Check if message contains word "results" and if so send results
if not message:
# number = s["session"]["parameters"]["numberToDial"]
number = s.parameters["numberToDial"]
reply = "Would you like to vote?"
t.call(to=number, network="SMS")
# t.say(reply)
elif message.lower().find("results") > -1:
results = get_results()
reply = ["The current standings are"]
for i, result in enumerate(results):
if i == 0:
reply.append(" *** %s is in the lead with %s percent of the votes.\n" % (result[0], str(round(result[2]))))
elif i <= 3:
reply.append(" - %s has %s percent of the votes.\n" % (result[0], str(round(result[2]))))
# Check if message contains word "options" and if so send options
elif message.lower().find("options") > -1:
options = get_options()
reply = ["The options are..."]
msg = ""
for option in options:
msg += "%s, " % (option)
msg = msg[:-2] + ""
reply.append(msg)
# Check if message contains word "vote" and if so start a voting session
elif message.lower().find("vote") > -1:
# reply = "Let's vote! Look for a new message from me so you can place a secure vote!"
reply = [process_incoming_message(message)]
# If nothing matches, send instructions
else:
# Reply back to message
# reply = "Hello, welcome to the MyHero Demo Room.\n" \
# "To find out current status of voting, ask 'What are the results?'\n" \
# "To find out the possible options, ask 'What are the options?\n" \
# '''To place a vote, simply type the name of your favorite Super Hero and the word "vote".'''
reply = ["Hello, welcome to the MyHero Demo Room." ,
"To find out current status of voting, ask 'What are the results?'",
"To find out the possible options, ask 'What are the options?",
'''To place a vote, simply type the name of your favorite Super Hero and the word "vote".''']
# t.say(["Really, it's that easy." + message])
t.say(reply)
response = t.RenderJson()
sys.stderr.write(response + "\n")
return response
示例12: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
t.call("sip:[email protected]:5678", say = "ha ha ha ha ha ah ah ah ah")
t.say("a b c d e f g h i j k")
on = On("connect", say = "emily", next = "http://freewavesamples.com/files/Kawai-K5000W-AddSquare-C4.wav", post = "http://192.168.26.88:8080/FileUpload/receiveJson").json
t.transfer(TO_NUMBER, _from= FROM_NUMBER, on=on, callbackUrl="http://192.168.26.88:8080/FileUpload/receiveJson", label="erthnbvc")
t.say("Hi. I am a robot q a z w s x e d c")
json = t.RenderJson()
print json
return json
示例13: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
mc = MachineDetection(introduction="This is a test. Please hold while I determine if you are a Machine or Human. Processing. Finished. THank you for your patience.", voice="Victor").json
t.call(to="+14071234321", machineDetection=mc)
t.on(event="continue", next="/continue.json")
return t.RenderJson()
示例14: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
t = Tropo()
t.call("sip:[email protected]:5678", say = "ha ha ha ha ha ah ah ah ah")
t.say("ah ah ah ah ah uh uh uh uh ha ha ha")
on1 = On("connect", ask = Ask(Choices("[5 DIGITS]")).json).json
on2 = On("ring", say = "emily2").json
t.transfer(TO_NUMBER, _from= FROM_NUMBER, on=[on1,on2], choices = TransferOnChoices(terminator = '#').json)
t.say("Hi. I am a robot")
json = t.RenderJson()
print json
return json
示例15: index
# 需要导入模块: from tropo import Tropo [as 别名]
# 或者: from tropo.Tropo import call [as 别名]
def index(request):
session = Session(request.body)
t = Tropo()
#jj = JoinPrompt(value = "who are you who let you come in")
jj = JoinPrompt("who are you who let you come in")
#ll = LeavePrompt(value = "byebye samsung")
ll = LeavePrompt("byebye samsung")
t.call(to=session.parameters['callToNumber'], network='SIP')
t.conference(id='yuxiangj', joinPrompt=jj.json, leavePrompt=ll.json)
t.say(session.parameters['message'])
return t.RenderJsonSDK()