From Bright Pattern Documentation
< 5.19:Workflow-builder-reference-guide
Revision as of 18:27, 11 February 2026 by Laura.donovan (talk | contribs) (Updated via BpClonePage extension. Source page: draft:Workflow-builder-reference-guide/AssociatingCallswithRelevantMicrosoftDynamicsRecords)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
• 5.19


Associating Calls with Relevant Microsoft Dynamics Records

If your contact center handles interactions via CRM integration, it is possible to automate post-interaction processing via workflows that use CRM variables. For instance, during a phone call, agents may view related cases, tasks, or contacts. Instead of requiring agents to manually enter phone call information and link the phone call record to those other related records, agents can simply mark the relevant records in the Communication Widget before triggering a workflow. The ensuing workflow can create a fully-populated phone call record in your CRM with links to all associated records selected by the agent.

Prerequisites

If you have not already done so, please configure your Microsoft Dynamics integration before proceeding.

Important: To enable agents to view and select associated records during an interaction, your integration must use the Communicator Widget, not the legacy Universal Repeater. As such, the Channel URL in the CIF app must be in the form

https://<tenantdomain>/agent/communicator/adapters/msdyn365.html?crmDomain=org<id>.crm.dynamics.com

For example:

https://example.brightpattern.com/agent/communicator/adapters/msdyn365.html?crmDomain=org12345678.crm.dynamics.com


Step 1. Configure an Inbound Voice Service

For an example of setting up an inbound voice service, scenario from template, and scenario entry, see Inbound Voice Service Configuration.

  1. Log in to Contact Center Administrator and navigate to Services and Campaigns.

  2. Set up the service for which you want to save CRM records; for example, a support hotline.
    Important: Enable Use dispositions in the Properties tab to enable agents to trigger workflows during ACW.
    The Properties tab of a service named "Support hotline," with the Use dispositions checkbox selected

  3. Navigate to Scenarios > Voice to create or reuse a scenario that identifies the contact associated with the caller. See Scenario Overview below for an example scenario.

  4. Navigate to Scenario Entries > Dial-in to create a scenario entry linking the scenario and service. For more information, see Dial-in.
    Screenshot of a scenario entry connecting the Find and screenpop contact scenario to the Support hotline service.

Scenario Overview

Screenshot of a voice scenario that uses Microsoft Dynamics scenario blocks to identify and display the caller to the agent

The following template serves as an example of a contact identification scenario: Find and Screenpop Contact Note that the $(D365.contactid) variable defined in this scenario is used in Step 2. Create a Workflow to Process Phone Call and Records below. The scenario logic is as follows:

  1. Accept the call.

  2. Wait a few seconds.

  3. Answer the call.

  4. Microsoft Dynamics Select Account: Select the desired Microsoft Dynamics integration.
  5.  
  6. Set Variable: Set isNewCaller to false.

  7. Microsoft Dynamics Search Object: Attempt to locate the contact ID of the caller by searching the Contacts table in Microsoft Dynamics for the caller's phone number.
    Microsoft Dynamics Search Object scenario block that searches the Contact table for the caller's phone number

    1. Select Contact from the Object type drop-down menu to search the Contacts table.

    2. In the Query field, enter the following: $select=contactid&$filter=contains(telephone1,'$(item.from)')

    3. Name a variable to store the query result in the Recordset name field, such as D365. The contact ID is stored in $(D365.contactid).

  8. If no contact with that phone number exists:

    1. Set Variable: Set isNewCaller to true.

    2. Microsoft Dynamics Create Object: Create a new contact with this phone number.
      A Microsoft Dynamics Create Object scenario block that creates a new contact with the current caller's phone number. The variable name for the object ID is D365.contactid

      1. Select Contact from the Object type drop-down menu.

      2. In the Variable name for Object ID field, enter D365.contactid. This ensures that the contact ID is stored in the same variable regardless of whether this is a new or pre-existing contact.

      3. Set the current caller's phone number as the contact's main phone number.
        Note: The agent will be prompted to name the new contact later in the scenario.
        {
         "telephone1": "$(item.from)"
        }
        

  9. Microsoft Dynamics Screenpop: Display the contact that was just found or created to the agent. In both cases, the contact ID is stored in the variable $(D365.contactid), which is referenced by the Object Identifier field.
    A Microsoft Dynamics Sceen Pop scenario block that displays the contact with the ID stored at $(D365.contactid) to the agent

  10. Find Agent

  11. If: Check whether isNewCaller has been set to true.
    An If scenario block with one conditional branch checking whether isNewCaller is true

    1. Internal Message: If isNewCaller is true, prompt the agent to enter a name for the new contact during the call.
      An Internal Message scenario block that prompts the agent to enter the new contact's first and last name

  12. Connect Call

  13. Exit

Step 2. Create a Workflow to Process Phone Call and Records

Next, we need to set up a workflow that creates and populates a new Phone Call object in your Microsoft Dynamics instance, then links that Phone Call to any records that the agent marked as relevant to the interaction. Since support hotline interactions are being handled via CRM integration, this workflow can use CRM variables such as $(associatedRecords). Click to download the Connect Records to Call example scenario, then import it into your contact center, or follow the steps below to create it from scratch.

  1. Navigate to Workflows, then click Add workflow in the bottom left to open the Workflow Builder.

  2. Name the new workflow in the top left of the Workflow Builder.

  3. Choose the desired integration account.

    1. Drag the Microsoft Dynamics Select Account block from the left sidebar to the center of the page to add it to the workflow.
      A MSDyn Select Account workflow block

    2. Select the CRM integration account in question from the dropdown in the rightmost panel.

  4. Find the current agent's Microsoft Dynamics user ID.

    1. Add a Microsoft Dynamics Search Object block to the workflow.
      A MSDyn Search Object workflow block titled "Get agent ID"

    2. In the Object type field, enter systemusers to search the User (SystemUser) table.
      Note: systemusers is the EntitySetName for the User (SystemUser) table in Microsoft Dynamics. For more information, see User (SystemUser) table/entity reference (Microsoft Dataverse).
      A Microsoft Dynamics Search Object workflow block that queries the systemusers table for the current agent's first and last name

    3. Using the Query field, locate the current agent's user ID by searching the User (SystemUser) table for their first and last name, which are stored at $(user.firstName) and $(user.lastName), respectively. $select=systemuserid&$filter=contains(lastname,'$(user.lastName)')&$filter=contains(firstname,'$(user.firstName)')

    4. Enter a descriptive variable name in the Recordset name field, such as agent. The agent's user ID is stored in $(agent.systemuserid).

  5. Set variables that format the call time, date, and duration for access by Microsoft Dynamics. For more information, see the Bright Pattern documentation for Workflow Variables and Built-In Functions.

    1. Add a Set Variable block with variable name time_start and value =formatdatetime(applytimezone((now()-$(duration)),"America/Los_Angeles"), "h:mm a"). This stores the time of day the call began in the call center's time zone, for use in the Phone Call object's Subject field.
      Note: $(duration) captures the call duration in seconds. now(), applytimezone(), and formatdatetime() are built-in functions that get and configure time information. Replace "America/Los_Angeles" in your own workflow with the relevant time zone in the form "Area/Location".
      Set Variable workflow block that uses built-in Bright Pattern functions to get the start time of the call

    2. Add a Set Variable block with variable name time_end and value =formatdatetime(applytimezone(now(),"America/Los_Angeles"), "yyyy-MM-dd'T'HH:mm'Z'"). This stores the date and time the call ended in ISO 8601 format, as required by the Phone Call object's ActualEnd field.
      Note: Replace "America/Los_Angeles" with the relevant time zone in the form "Area/Location".
      Set Variable workflow block that uses built-in Bright Pattern functions to get the end time and date of the call

    3. Add a Set Variable block with variable name duration_min and value =($(duration)/60). This calculates the call duration in minutes, as required by the Phone Call object's ActualDurationMinutes field.
      Set Variable workflow block that calculates the call duration in minutes

  6. Create a new Phone Call CRM object for this hotline call.

    1. Add a Microsoft Dynamics Create Object block.
      A Microsoft Dynamics Create Object workflow block

    2. In the Object type field, enter phonecalls to create a new Phone Call object.
      Note: phonecalls is the EntitySetName for the Phone Call (PhoneCall) table in Microsoft Dynamics. For more information, see Phone Call (PhoneCall) table/entity reference (Microsoft Dataverse).
      A Microsoft Dynamics Create Object workflow block that creates a new record in the Phone Call table and populates it with call information

    3. Enter a descriptive name in the Variable name for Object ID field. In this example, we use call_new.

    4. In the JSON field, populate the Phone Call record with relevant data and bind it to the customer's contact ID and agent's user ID in the following format.
      Note: This field uses the $(D365.contactid) variable from the scenario defined above. participationtypemask: 1 indicates the caller, while 2 indicates the recipient. directioncode: false means inbound, while true means outbound.
      {
       "phonenumber": "$(item.from)",
       "subject": "New hotline call at $(time_start)",
       "description": "$(disposition)\n$(notes)",
       "directioncode": false,
       "actualdurationminutes": "$(duration_min)",
       "actualend": "$(time_end)",
       "phonecall_activity_parties": [
        {
         "participationtypemask": 2,
         "partyid_systemuser@odata.bind": "/systemusers($(agent.systemuserid))"
        },
        {
         "participationtypemask": 1,
         "partyid_contact@odata.bind": "/contacts($(D365.contactid))"
        }
       ]
      }
      

  7. Mark the phone call as complete.

    1. Add a Microsoft Dynamics Update Object block.
      A Microsoft Dynamics Update Object workflow block titled "Set call status to complete"

    2. In the Object type field, enter phonecalls.
      A Microsoft Dynamics Update Object workflow block that updates the state and status of the $(call_new) object

    3. In the Object Identifier field, enter $(call_new) to specify the object created in step 6 above.

    4. In the JSON field, update the state and status codes as follows:
      {
       "statecode": 1,
       "statuscode": 2
      }
      

  8. Since the agent can select multiple records to associate with the call, we need to set up a loop that checks the number of records in the array and connects each one to the Phone Call object. If multiple records are selected, the workflow will run through the loop one time for each record in the array. If only one record is selected, the workflow will run through the loop once, then stop. If no records are selected, the workflow will skip the loop entirely.

    1. Add a Set Variable block with variable name i and value 0. This creates an index variable to step through the array, starting with the first record at index 0.
      A Set Variable workflow block setting i to 0

    2. Add an If block that checks that the current index at $(i) is less than the length of the $(associatedRecords) JSON array.
      An If workflow block with a conditional branch titled "Array traversal" that creates an MS Dynamics Connection object, increments the index variable by 1, and loops back to the beginning of the If block

      1. Press the Add branch button.

      2. Name the branch via the Exit label field. In this example, we use the name Array traversal.

      3. Click Add condition.

      4. Configure the fields such that they read Workflow variable (number) i is < $(numberOfAssociatedRecords). Then, click the green checkmark.
        If block condition checking that the current index variable i is less than the length of the associatedRecords array

    3. Within the Array traversal branch, add a Microsoft Dynamics Create Object block. Leave it blank for now.

    4. Below the Create Object block, add another Set Variable block with variable name i and value =$(i)+1. This increments the index variable by 1.

    5. Below the Set Variable block, add a Goto block. In the rightmost panel, select the If block to return to the beginning of the loop.

  9. Return to the Microsoft Dynamics Create Object block you added in step 8c to create a Connection between the Phone Call and the current record in the array.
    A MS Dynamics Create Object workflow block creating an active Connection between the Phone Call object and the current associated record

    1. In the Object type field, enter connections to create a new Connection record.

    2. Enter a descriptive name in the Variable name for Object ID field. In this example, we use conn_new.

    3. In the JSON field, bind record1 to the Phone Call and record2 to the current associated record, then mark the Connection status as active.
      Note:  For more information on Connection properties, see Connection table/entity reference (Microsoft Dataverse).
      {
       "record1id_phonecall@odata.bind": "/phonecalls($(call_new))",
       "record2id_$(associatedRecords.$(i).objectType)@odata.bind":  "/$(associatedRecords.$(i).objectType)s($(associatedRecords.$(i).objectId))",
       "statecode": 0,
       "statuscode": 1
      }
      

  10. Add an Exit block below the If block and outside of the Array traversal branch to end the workflow.
    An Exit block at the end of a workflow

  11. Press the Save button at the bottom of the page.

Step 3. Create a Workflow Entry

All that remains is to connect the workflow to the support hotline service via a Workflow Entry, and to set one or more triggers.

  1. Click the Workflow Entries tab for your new workflow.

  2. Give the workflow entry a descriptive name.

  3. Select the service that you created earlier from the drop-down menu.
    Several fields in a workflow entry associated with the Support hotline service

  4. Set one or more workflow triggers. For more information, see Triggers in the Workflow Builder Overview.
    Screenshot of the two drop-down menus that appear when adding a trigger to a workflow entry

    • Select Agent completes interaction with disposition to run the workflow for each agent that participates in the call, which will create a call record per agent segment.

    • Select Interaction ends with last disposition to run this workflow once the interaction is completed, creating a single call object for the entire interaction.

    • Select the desired disposition from the second drop-down menu, or select Any disposition to run the workflow after any call to the Support hotline service.

  5. Press Apply.

Step 4. Trigger the Workflow

  1. An agent who is assigned to the Support hotline service enters the Ready state.

  2. The agent accepts an incoming call. During the interaction, they may view related records, such as contacts, cases, tasks, or accounts. These records will appear in the widget under the Records tab.
    Screenshot of the Communicator Widget Records tab mid-call associated with the Support hotline service

  3. After the interaction ends, the agent can do the following:

    1. Select a disposition from the drop-down menu.

    2. Select all records that are relevant to the call.
      Screenshot of the Communicator Widget Records tab after a Support hotline call, with several Task, Case, and Contact records selected

    3. Press Complete to submit.

  4. If the selected disposition matches the trigger in the workflow entry, the workflow will begin, automatically creating a Phone Call record connected to the selected CRM records.

View Connections in Microsoft Dynamics

Connections created by this workflow can be viewed in the Phone Call record as well as the records selected by the agent.

Screenshot of the Connections tab on a Contact page in Microsoft Dynamics

  1. Open the Phone Call record in your Microsoft Dynamics instance.
    Note: Since this Phone Call record is marked complete, it only appears on the Activities page under the following views: All Activities, Closed Activities, My Closed Activities, All Phone Calls, and My Completed Phone Calls.
    Screenshot of the My Closed Activities page in Microsoft Dynamics, showing a phone call titled "New hotline call at 2:01 PM"
  2. Click on the Related tab, then select Connections from the drop-down menu.
    Screenshot of the Related drop-down menu of a Microsoft Dynamics Phone Call record

  3. View all connections to this record in the Connections tab.
    Screenshot of the Connections tab of a Microsoft Dynamics Phone Call record, showing four active connections

    < Previous | Next >