• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python rest.TwilioTaskRouterClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twilio.rest.TwilioTaskRouterClient的典型用法代码示例。如果您正苦于以下问题:Python TwilioTaskRouterClient类的具体用法?Python TwilioTaskRouterClient怎么用?Python TwilioTaskRouterClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TwilioTaskRouterClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:malaklopez,项目名称:task-router-django,代码行数:13,代码来源:views.py


示例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)
开发者ID:lyft,项目名称:twilio-python,代码行数:57,代码来源:test_client.py


示例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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:16,代码来源:example-1.5.x.py


示例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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:18,代码来源:example-1.5.x.py


示例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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:24,代码来源:example-1.5.x.py


示例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)
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:27,代码来源:example-1.5.x.py


示例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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:20,代码来源:example-1.5.x.py


示例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)
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:18,代码来源:example-1.5.x.py


示例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)
开发者ID:aaalaniz,项目名称:api-snippets,代码行数:18,代码来源:example-2.5.x.py


示例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
开发者ID:crtr0,项目名称:api-snippets,代码行数:12,代码来源:example-1.py


示例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 = []
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:31,代码来源:example-1.5.x.py


示例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)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:15,代码来源:example-1.5.x.py


示例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)

开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:16,代码来源:example-1.5.x.py


示例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)
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:14,代码来源:example-1.5.x.py


示例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)

开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:24,代码来源:example-1.5.x.py


示例16: 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)

task = client.tasks(workspace_sid).get(task_sid)
print(task.attributes)
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:13,代码来源:example-1.5.x.py


示例17: 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)

statistics = client.workers(workspace_sid).get(worker_sid).statistics.get()
print(statistics.cumulative["reservations_accepted"])
开发者ID:TwilioDevEd,项目名称:api-snippets,代码行数:13,代码来源:example-1.5.x.py


示例18: 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 }}"
task_sid = "{{ task_sid }}"
reservation_sid = "{{ reservation_sid }}"

client = TwilioTaskRouterClient(account_sid, auth_token)

# reject a reservation
reservation = client.reservations(workspace_sid, task_sid).update(reservation_sid, reservation_status='rejected')
print reservation.reservation_status
print reservation.worker_name

开发者ID:crtr0,项目名称:api-snippets,代码行数:16,代码来源:example-1.py


示例19: 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 taskqueue in client.taskqueues(workspace_sid).list():
	print taskqueue.friendly_name
开发者ID:crtr0,项目名称:api-snippets,代码行数:12,代码来源:example-1.py


示例20: 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)

worker = client.workers(workspace_sid).create(
    friendly_name='Support Worker 1', attributes='{"type":"support"}'
)

print(worker.friendly_name)
开发者ID:GilbertoBotaro,项目名称:api-snippets,代码行数:15,代码来源:example-1.5.x.py



注:本文中的twilio.rest.TwilioTaskRouterClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python resources.PhoneNumbers类代码示例发布时间:2022-05-27
下一篇:
Python rest.TwilioRestClient类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap