示例#1
0
    def start(self):
        account_sid = "AC36a9938f19a9480c595e857f2f1af7dd"
        auth_token = "264a2e58db9f0ccc58a3003c2c472164"
        print "test test"
        client = TwilioTaskRouterClient(account_sid, auth_token)

        # read in the age, and default to `0` if invalid or missing
        text = self.db.flow.get('text') or ""
        taskSid = self.db.user.user_id
        print self.db.user.user_id
        taskSid = "WTa38157b48040c397d19781f1857e05eb"
        angry_words = ['cancel', 'hate', 'suck', 'yelp']
        words_re = re.compile("|".join(angry_words))
        if words_re.search(text):
            action = "angry"
        else:
            action = "happy"
        task = client.tasks("WS056355824815f89c7cc46e5d8cacaf20").get(taskSid)
        task_attributes = json.loads(task.attributes)
        task_attributes['bot_qualified'] = 'true'
        task_attributes['bot_intent'] = action
        print task_attributes
        attribute_string = json.dumps(task_attributes)
        task = client.tasks("WS056355824815f89c7cc46e5d8cacaf20").update(
            taskSid, attributes=attribute_string)
        message = self.create_message(text=self.db.user.user_id)
        # the action determines which transition is invoked
        # note that no message is returned, just an action
        return self.respond(message=None, action=action)
示例#2
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "{{ account_sid }}"
auth_token  = "{{ auth_token }}"
workspace_sid = "{{ workspace_sid }}"

client = TwilioTaskRouterClient(account_sid, auth_token)

for task in client.tasks(workspace_sid).list():
	print task.attributes
示例#3
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
task_sid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

# update a task's attributes
task = client.tasks(workspace_sid).update(task_sid,
                                          attributes='{"type":"support"}')
print(task.attributes)

# alternatively
task = client.tasks(workspace_sid).get(task_sid)
task = task.update(attributes='{"type":"support"}')
print(task.attributes)

# cancel a task
task = client.tasks(workspace_sid).update(task_sid,
                                          assignment_status='canceled',
                                          reason='waiting too long')
print(task.assignment_status)
print(task.reason)
示例#4
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

task = client.tasks(workspace_sid).create(workflow_sid=workflow_sid,
                                          attributes='{"type":"support"}')

print(task.attributes)
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "{{ account_sid }}"
auth_token = "{{ auth_token }}"
workspace_sid = "{{ workspace_sid }}"
task_sid = "{{ task_sid }}"

client = TwilioTaskRouterClient(account_sid, auth_token)

task = client.tasks(workspace_sid).get(task_sid)
print task.attributes
示例#6
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
task_sid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

task = client.tasks(workspace_sid).get(task_sid)
print(task.attributes)
示例#7
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

for task in client.tasks(workspace_sid).list():
    print(task.attributes)
示例#8
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

for task in client.tasks(workspace_sid).list(
    TaskQueueSid="WQf855e98ad280d0a0a325628e24ca9627"
):
    print(task.attributes)

for task in client.tasks(workspace_sid).list(AssignmentStatus="pending"):
    print(task.attributes)
"""
Delete all tasks currently in OneRoute Twilio Workspace
"""
from twilio.rest import TwilioTaskRouterClient
account_sid = "ACc9111e5c0efc0644b4e754bf2183c1c2"
auth_token = "86f3177a99d46d4cb6237b106be7bd9c"
workspace_sid = "WSa521ebd8b208fe727465ceb9c92bfc52"
task_router = TwilioTaskRouterClient(account_sid, auth_token)

for task in task_router.tasks(workspace_sid).list():
    task.delete()
    print task.sid + " has been removed from Twilio."
示例#10
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token  = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
task_sid = "WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

# update a task's attributes
task = client.tasks(workspace_sid).update(task_sid, attributes='{"type":"support"}')
print(task.attributes)

# alternatively
task = client.tasks(workspace_sid).get(task_sid)
task = task.update(attributes='{"type":"support"}')
print(task.attributes)

# cancel a task
task = client.tasks(workspace_sid).update(task_sid, assignment_status='canceled', reason='waiting too long')
print(task.assignment_status)
print(task.reason)

# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"
workspace_sid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
workflow_sid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

client = TwilioTaskRouterClient(account_sid, auth_token)

task = client.tasks(workspace_sid).create(
    workflow_sid=workflow_sid, attributes='{"type":"support"}'
)

print(task.attributes)