Skip to content

Instantly share code, notes, and snippets.

@abhijitmehta
Last active February 27, 2021 08:44
Show Gist options
  • Save abhijitmehta/9104bf4706e8006af2f9fab39cc907a8 to your computer and use it in GitHub Desktop.
Save abhijitmehta/9104bf4706e8006af2f9fab39cc907a8 to your computer and use it in GitHub Desktop.
Script for Sequence diagram to build preview dialing on Flex using Flex Action startOutboundCall and Task Creation API

Preview Dialing on Flex using Flex Action startOutboundCall and Task Creation API

Preview Dialing

Diagram Script

title Preview Dialing on Flex using Flex Action startOutboundCall and Task Creation API

loop over all customers in a Campaign
Preview Dialer --> Campaign : Get next Customer
Campaign->Preview Dialer : Next Customer
Preview Dialer->Flex: Create Task
note left of Flex 
POST /Tasks
{
      to: customerData.phoneNumber,
      direction: "outbound",
      name: "Next Customer :  " + callBackData.your_contact_number,
      type: "preview_170483",
      customerData: customerData
    }),
    workflowSid: context.WorkflowSid,
    taskChannel: context.TaskChannelSid
  };

end note
Flex->Agent: Here's a task for you. Accept to start the call
Agent->Flex: Accept 
note over Flex Plugin
    # if accepted Task is of type "preview_170483" , 
    # then complete this task and start outbound call 
    flex.Actions.addListener("afterAcceptTask", (payload, abortFunction) => {
      if (payload.task.attributes.type === "preview_170483") {
        flex.Actions.invokeAction("StartOutboundCall", {
          destination: payload.task.attributes.to
        });
      }

      flex.Actions.invokeAction("CompleteTask", { sid: payload.task.sid });
    });

end note
Flex Plugin->Flex : Complete task 
Flex Plugin->Flex : Perform outbound Call
Flex->Destination : Outbound Callend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment