本文整理汇总了Python中twilio.rest.TwilioTaskRouterClient类的典型用法代码示例。如果您正苦于以下问题:Python TwilioTaskRouterClient类的具体用法?Python TwilioTaskRouterClient怎么用?Python TwilioTaskRouterClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TwilioTaskRouterClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: incoming_sms
def incoming_sms(request):
""" Changes worker activity and returns a confirmation """
client = TwilioTaskRouterClient(ACCOUNT_SID, AUTH_TOKEN)
activity = 'Idle' if request.POST['Body'].lower().strip() == 'on' else 'Offline'
activity_sid = WORKSPACE_INFO.activities[activity].sid
worker_sid = WORKSPACE_INFO.workers[request.POST['From']]
workspace_sid = WORKSPACE_INFO.workspace_sid
client.workers(workspace_sid).update(worker_sid, activity_sid=activity_sid)
resp = twiml.Response()
message = 'Your status has changed to ' + activity
resp.message(message)
return HttpResponse(resp)
示例2: RestClientTest
class RestClientTest(unittest.TestCase):
def setUp(self):
self.client = TwilioRestClient("ACCOUNT_SID", "AUTH_TOKEN")
self.task_router_client = TwilioTaskRouterClient("ACCOUNT_SID",
"AUTH_TOKEN")
@patch("twilio.rest.base.make_request")
def test_request(self, mock):
self.client.request("2010-04-01", method="GET")
mock.assert_called_with("GET", "https://api.twilio.com/2010-04-01",
headers={"User-Agent": ANY,
'Accept-Charset': 'utf-8',
'Authorization':
'Basic QUNDT1VOVF9TSUQ6QVVUSF9UT0tFTg=='},
params={}, auth=AUTH, data=None)
called_kwargs = mock.mock_calls[0][2]
self.assertTrue(
'twilio-python' in called_kwargs['headers']['User-Agent']
)
def test_connect_apps(self):
assert_true(isinstance(self.client.connect_apps,
resources.ConnectApps))
def test_authorized_apps(self):
assert_true(isinstance(self.client.authorized_connect_apps,
resources.AuthorizedConnectApps))
@patch("twilio.rest.resources.base.make_request")
def test_conferences(self, mock):
mock.return_value = Mock()
mock.return_value.ok = True
mock.return_value.content = '{"conferences": []}'
self.client.conferences.list()
@patch("twilio.rest.resources.base.make_twilio_request")
def test_members(self, mock):
resp = create_mock_json("tests/resources/members_list.json")
mock.return_value = resp
self.client.members("QU123").list()
uri = "https://api.twilio.com/2010-04-01/Accounts/ACCOUNT_SID" \
"/Queues/QU123/Members"
mock.assert_called_with("GET", uri, params={}, auth=AUTH,
use_json_extension=True)
@patch("twilio.rest.resources.base.make_request")
def test_workflows(self, request):
resp = create_mock_json(
"tests/resources/task_router/workflows_list.json"
)
request.return_value = resp
workflows = self.task_router_client.workflows("WS123")
workflows = workflows.list()
assert_true(workflows[0].sid is not None)
uri = "https://taskrouter.twilio.com/v1/Workspaces/WS123/Workflows"
request.assert_called_with("GET", uri, headers=ANY, params={},
auth=AUTH)
示例3: TwilioTaskRouterClient
# 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)
示例4: TwilioTaskRouterClient
# 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)
taskqueue = client.task_queues(workspace_sid).create(
friendly_name='English',
reservation_activity_sid='WAxxxx',
assignment_activity_sid='WAyyyy',
target_workers='languages HAS "english"'
)
print(taskqueue.friendly_name)
示例5: TwilioTaskRouterClient
# 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"
worker_sid = "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
reservation_sid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client = TwilioTaskRouterClient(account_sid, auth_token)
call_status_callback_url = 'http://example.com/agent_answer_status_callback'
# call using a reservation
reservation = client.workers(workspace_sid).get(worker_sid) \
.reservations.update(
reservation_sid,
instruction='call',
call_from='+15558675309',
call_url='http://example.com/agent_answer',
call_status_callback_url=call_status_callback_url,
call_accept='true')
print(reservation.reservation_status)
print(reservation.worker_name)
示例6: TwilioTaskRouterClient
# 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"
worker_sid = "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
reservation_sid = "WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client = TwilioTaskRouterClient(account_sid, auth_token)
# call using a reservation
reservation = (
client.workers(workspace_sid)
.get(worker_sid)
.reservations.update(
reservation_sid,
instruction="call",
call_from="+15558675309",
call_url="http://example.com/agent_answer",
call_status_callback_url="http://example.com/agent_answer_status_callback",
call_accept="true",
)
)
print(reservation.reservation_status)
print(reservation.worker_name)
示例7: TwilioTaskRouterClient
# 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"
worker_sid = "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client = TwilioTaskRouterClient(account_sid, auth_token)
activity = client.workers(workspace_sid).update(
worker_sid, attributes='{"type":"support"}'
)
print(activity.friendly_name)
# alternatively
worker = client.workers(workspace_sid).get(worker_sid)
worker = worker.update(attributes='{"type":"support"}')
print(worker.attributes)
示例8: TwilioTaskRouterClient
# 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"
taskqueue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client = TwilioTaskRouterClient(account_sid, auth_token)
taskqueue = client.task_queues(workspace_sid).update(taskqueue_sid, target_workers='languages HAS "english"')
print(taskqueue.target_workers)
# alternatively
taskqueue = client.task_queues(workspace_sid).get(taskqueue_sid)
taskqueue = taskqueue.update(target_workers='languages HAS "english"')
print(taskqueue.target_workers)
示例9: TwilioTaskRouterClient
# 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 worker in client.workers(workspace_sid).list(Available=1):
print(worker.friendly_name)
for worker in client.workers(workspace_sid).list(TaskQueueSid="WQf855e98ad280d0a0a325628e24ca9627", Available=1):
print(worker.friendly_name)
for worker in client.workers(workspace_sid).list(TargetWorkersExpression="type == 'leads'"):
print(worker.friendly_name)
示例10: TwilioTaskRouterClient
# 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 worker in client.workers(workspace_sid).list():
print worker.friendly_name
示例11: TwilioTaskRouterClient
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioTaskRouterClient
from twilio.task_router.workflow_ruletarget import WorkflowRuleTarget
from twilio.task_router.workflow_rule import WorkflowRule
from twilio.task_router.workflow_config import WorkflowConfig
# 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)
rules = []
sales_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
marketing_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
support_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
everyone_queue_sid = "WQXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
salesRuleTargets = []
salesRuleTarget = WorkflowRuleTarget(sales_queue_sid, None, None, None)
salesRuleTargets.append(salesRuleTarget)
salesRule = WorkflowRule("type=='sales'", salesRuleTargets, None)
marketingRuleTargets = []
marketingRuleTarget = WorkflowRuleTarget(marketing_queue_sid, None, None, None)
marketingRuleTargets.append(marketingRuleTarget)
marketingRule = WorkflowRule("type=='marketing'", marketingRuleTargets, None)
supportRuleTargets = []
示例12: TwilioTaskRouterClient
# 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)
activity = client.activities(workspace_sid).create(
friendly_name='NewAvailableActivity', available='true'
)
print(activity.friendly_name)
示例13: TwilioTaskRouterClient
# 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"
worker_sid = "WKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
reservation_sid = 'WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
client = TwilioTaskRouterClient(account_sid, auth_token)
# reject a reservation
reservation = client.workers(workspace_sid).get(worker_sid).reservations.update(reservation_sid, reservation_status='rejected')
print(reservation.reservation_status)
print(reservation.worker_name)
示例14: TwilioTaskRouterClient
# 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)
for reservation in client.reservations(workspace_sid, task_sid).list():
print(reservation.reservation_status)
print(reservation.worker_name)
示例15: TwilioTaskRouterClient
# 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)