Пример #1
0
def create_workflow(workspace, queues):
    defaultRuleTarget = WorkflowRuleTarget(queues['default'].sid, '1==1', 1, 30)

    rules = []
    queueRuleTargets = []
    queueRuleTarget = WorkflowRuleTarget(queues['sms'].sid, None, 5, 30)
    queueRuleTargets.append(queueRuleTarget)
    queueRuleTargets.append(defaultRuleTarget)
    rules.append(
            WorkflowRule("selected_product==\"ProgrammableSMS\"",
                         [queueRuleTarget, defaultRuleTarget], None))
    queueRuleTargets = []
    queueRuleTarget = WorkflowRuleTarget(queues['voice'].sid, None, 5, 30)
    queueRuleTargets.append(queueRuleTarget)
    queueRuleTargets.append(defaultRuleTarget)
    rules.append(
            WorkflowRule("selected_product==\"ProgrammableVoice\"",
                         [queueRuleTarget, defaultRuleTarget], None))

    config = WorkflowConfig(rules, defaultRuleTarget)
    callback_url = HOST + '/assignment'
    return CLIENT.workflows(workspace.sid).create(
        friendly_name='Sales',
        assignment_callback_url=callback_url,
        fallback_assignment_callback_url=callback_url,
        task_reservation_timeout=15,
        configuration=config.to_json())
 def test_to_json(self):
     rules = [
         WorkflowRule("1==1", [WorkflowRuleTarget("WQeae4fc2f4db7f377c5d3758fb08b79b7", "1==1", 1, 20)], "SomeQ"),
         WorkflowRule("1==1", [WorkflowRuleTarget("WQ19ebe92fb33522f018b5a31d805d94da", "1==1", 1, 210)], "SomeOtherQ")
     ]
     def_target = WorkflowRuleTarget("WQ9963154bf3122d0a0558f3763951d916", "1==1", None, None)
     config = WorkflowConfig(rules, def_target)
     self.assertEqual(True, self.is_json(config.to_json()))
Пример #3
0
 def test_to_json(self):
     rules = [
         WorkflowRule("1==1", [
             WorkflowRuleTarget("WQeae4fc2f4db7f377c5d3758fb08b79b7",
                                "1==1", 1, 20)
         ], "SomeQ"),
         WorkflowRule("1==1", [
             WorkflowRuleTarget("WQ19ebe92fb33522f018b5a31d805d94da",
                                "1==1", 1, 210)
         ], "SomeOtherQ")
     ]
     def_target = WorkflowRuleTarget("WQ9963154bf3122d0a0558f3763951d916",
                                     "1==1", None, None)
     config = WorkflowConfig(rules, def_target)
     self.assertEqual(True, self.is_json(config.to_json()))
Пример #4
0
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 = []
supportRuleTarget = WorkflowRuleTarget(support_queue_sid, None, None, None)
supportRuleTargets.append(supportRuleTarget)
supportRule = WorkflowRule("type=='support'", supportRuleTargets, None)

rules.append(salesRule)
rules.append(marketingRule)
rules.append(supportRule)

defaultTarget = WorkflowRuleTarget(everyone_queue_sid, None, None, None)
config = WorkflowConfig(rules, defaultTarget)
json = config.to_json()

workflow = client.workflows(workspace_sid).create(
    friendly_name='Sales, Marketing, Support Workflow',
    assignment_callback_url='http://example.com',
    fallback_assignment_callback_url='http://example2.com',
    task_reservation_timeout='30',
    configuration=json)

print(workflow.friendly_name)
Пример #5
0
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 = []
supportRuleTarget = WorkflowRuleTarget(support_queue_sid, None, None, None)
supportRuleTargets.append(supportRuleTarget)
supportRule = WorkflowRule("type=='support'", supportRuleTargets, None)

rules.append(salesRule)
rules.append(marketingRule)
rules.append(supportRule)

defaultTarget = WorkflowRuleTarget(everyone_queue_sid, None, None, None)
config = WorkflowConfig(rules, defaultTarget)
json = config.to_json()

workflow = client.workflows(workspace_sid).create(
    friendly_name='Sales, Marketing, Support Workflow',
    assignment_callback_url='http://example.com',
    fallback_assignment_callback_url='http://example2.com',
    task_reservation_timeout='30',
    configuration=json
)

print(workflow.friendly_name)