Walkthrough 7: Configure agent scripting in agent applications

Agent scripting in Unified Service Desk helps to guide your agents during customer interaction. This walkthrough demonstrates how to create a simple agent script that helps the agents quickly create a new case for an account or browse existing cases from the agent application. The agent script created in this walkthrough is invoked when the agent pulls up an account record to view, which is displayed in a session in the Unified Service Desk client. The script provides the following three options:

  • Create a case for the current account

  • Display existing cases for the current account

  • Close the session

Prerequisites

In This Walkthrough

Step 1: Create an Agent Scripting type of hosted control

Step 2: Create hosted controls to display the new case form and existing cases

Step 3: Create an agent script task

Step 4: Add the answer, action call, and window navigation rule for creating a case from the agent script

Step 5: Add the answer and action calls for displaying existing cases

Step 6: Add the answer and action calls for closing the session

Step 7: Create an action call to display the agent script

Step 8: Display the agent script when the account record is displayed in a session

Step 9: Add the controls to the configuration

Step 10: Test the application

Conclusion

Step 1: Create an Agent Scripting type of hosted control

An instance of the Agent Scripting type of hosted control must be available in your agent application to display agent scripts.

  1. Sign in to Unified Service Desk Administrator.

  2. Select Hosted Controls under Basic Settings.

  3. Select + New.

  4. On the New Hosted Control page, specify the following values:

    Field Value
    Name Contoso Agent Scripting
    USD Component Type Agent Scripting
    Display Group WorkflowPanel
  5. Select Save.

Step 2: Create hosted controls to display the new case form and existing cases

In this step, you’ll create two hosted controls of Unified Interface Page type to display the new case creation form and existing cases for the current account.

  1. On the hosted controls page, select + New.

  2. On the New Hosted Control page, specify the following values:

    Field Value
    Name Contoso new case form
    Display Name New Case
    USD Component Type Unified Interface Page
    Allow Multiple Pages No
    Application is Global Not checked
    Display Group MainPanel
  3. Select Save.

  4. On the hosted controls page, select + New to create another hosted control.

  5. On the New Hosted Control page, specify the following values:

    Field Value
    Name Contoso existing cases for an account
    Display Name Cases for [[$Context.name]]
    Note: We are using the replacement parameter to dynamically display the name of the current account from the execution context as the hosted control display name.
    USD Component Type Unified Interface Page
    Allow Multiple Pages No
    Application is Global Not checked
    Display Group MainPanel
  6. Select Save.

Step 3: Create an agent script task

Create an agent script task to display when an account record is displayed in a session.

  1. Sign in to Unified Service Desk Administrator.

  2. Select Agent Scripts under Basic Settings.

  3. Select + New.

  4. On the New Agent Script Task page, specify the following values:

    Field Value
    Name Contoso: Welcome to Account Session
    Start Task No
    ScriptText Welcome [[$Context.name]]. My name is [[$User.firstname]]. Is this call regarding a new or an existing service request?
    Note: We are using replacement parameters to dynamically display the account name and the current agent’s name to the agent at runtime.
    Instructions Based on the customer response, select one of the tasks below.
  5. Select Save to create the agent script.

Step 4: Add the answer, action call, and window navigation rule for creating a case from the agent script

In this step, you’ll create answer, action call, and window navigation rule for displaying a new case form with some prepopulated values from the currently active account record.

  1. In the Answers area of the agent script task that you created in step 4, select Add Existing Agent Script Answer to create answer. The Lookup Records pane is displayed.

  2. Select the search icon, and then select + New Agent Script Answer.

  3. On the New Agent Script Answer page, specify the following values:

    Field Value
    Name Contoso: New case
    Answer Text Create a case
    Linked Task Contoso: Welcome to Account Session
    Order 1
  4. Select Save.

  5. Next, add an action call to this answer to display a new case form for the account when the agent selects this answer. Select the Related tab, and then select Actions.

  6. On the next page, select Add Existing Action Call. The Lookup records pane is displayed.

  7. Select the search icon in the search box, and then select + New Action Call to create an action call.

  8. On the New Action Call page, specify the following values:

    Field Value
    Name Contoso Action Call: Create Case
    Order 1
    Hosted Control Contoso new case form
    Action New_CRM_Page
    Data LogicalName=incident
    customerid=EntityReference([[$Context.InitialEntity]],[[$Context.Id]])
    customeridname=[[$Context.name]]
    primarycontactid=[[$Context.primarycontactid.id]+]
    primarycontactidname=[[$Context.primarycontactid.name]+]
    Note: The new case form will be populated with the current account record data to help the agent quickly create a case for the customer.
  9. Select Save.

  10. Select the back button on the browser to go back to the Contoso: New case page.

  11. Select Add Existing Action Call. The Lookup records pane is displayed.

  12. Type the name of the action call. Select the record from the search results, and then select Add.

  13. Next, create a window navigation rule to display the new case form. Go to Settings > Unified Service Desk.

Select Window Navigation Rules.

  1. Select + New.

  2. On the New Window Navigation Rule page, specify the following values.

    Field Value
    Name Contoso New Case for Account Session Rule
    Order 20
    From Contoso new case form
    Entity incident
    Route Type In Place
    Destination Tab
    Action In Place
    Hide Command Bar No
    Hide Navigation Bar Yes
  3. Select Save.

Step 5: Add the answer and action calls for displaying existing cases

In this step, add answer and action calls for displaying existing cases for the current account.

  1. In the Answers area of the Contoso: Welcome to Account Session agent script, select + Add Existing Agent Script Answer to create an answer.

  2. Select the search icon, and then select + New Agent Script Answer.

  3. On the New Agent Script Answer page, specify the following values.

    Field Value
    Name Contoso: Existing cases
    Answer Text Display existing cases
    Linked Task Contoso: Welcome to Account Session
    Order 2
  4. Select Save.

  5. Next, add an action call to this answer to display the existing cases for the current account. Select the Related tab, and then select Actions.

  6. On the next page, select Add Existing Action Call.

  7. Select the search icon in the search box, and then select + New Action Call to create an action call.

  8. On the New Action Call page, specify the following values:

    Field Value
    Name Contoso Action Call: Display Existing Cases
    Order 1
    Hosted Control Contoso existing cases for an account
    Action AssociatedView
    Data etn=[[$Context.InitialEntity]]
    id=[[$Context.Id]]
    navitemid=navService
  9. Select Save.

  10. Add another action call to set the focus on the new case form. Repeat Steps 6 and 7, and specify the following values:

    Field Value
    Name Contoso Action Call: Set Focus on Existing Cases
    Order 2
    Hosted Control Contoso Global Manager
    Action ShowTab
    Data Contoso existing cases for an account
  11. Select Save.

  12. Select the back button on the browser to go back to the Contoso: New case page.

  13. Select Add Existing Action Call. The Lookup records pane is displayed.

  14. Type the name of the action call. Select the record from the search results, and then select Add.

  15. Select Save.

Step 6: Add the answer and action calls for closing the session

In this step, add answer and action calls for closing the current session.

  1. In the Answers area of the Contoso: Welcome to Account Session agent script, select + Add Existing Agent Script Answer to create an answer.

  2. Select the search icon, and then select + New Agent Script Answer.

  3. On the New Agent Script Answer page, specify the following values.

  4. On the New Agent Script Answer page, specify the following values:

    Field Value
    Name Contoso: Close session
    Answer Text Close session
    Linked Task Contoso: Welcome to Account Session
    Order 3
  5. Select Save.

  6. Next, add an action call to this answer to close the session. Select the Related tab, and then select Actions.

  7. On the next page, select Add Existing Action Call.

  8. Select the search icon in the search box, and then select + New Action Call to create an action call.

  9. On the New Action Call page, specify the following values:

    Field Value
    Name Contoso Action Call: Close Session
    Hosted Control Contoso Session Tab
    Note: The Contoso Session Tab hosted control was created in Walkthrough 4: Display a model-driven app (Unified Interface apps) record in a session in your agent application.
    Action CloseSession
    Data sessionid=[[$Context.SessionId]]
  10. Select Save.

  11. Select the back button on the browser to go back to the Contoso: New case page.

  12. Select Add Existing Action Call. The Lookup records pane is displayed.

  13. Type the name of the action call. Select the record from the search results, and then select Add.

  14. Select Save.

Step 7: Create an action call to display the agent script

In this step, create an action call to display the agent script.

  1. Sign in to Unified Service Desk Administrator.

  2. Select Action Calls under Basic Settings.

  3. Select + New.

  4. On the New Action Call page, specify the following values.

    Field Value
    Name Contoso Action Call: Load Agent Script
    Hosted Control Contoso Agent Scripting
    Action GoToTask
    Data Contoso: Welcome to Account Session
  5. Select Save.

Step 8: Display the agent script when the account record is displayed in a session

In this step, add the action call created in the previous step to the PageReady event on the Contoso Account Session hosted control so that after it’s loaded, the action call is executed to load the agent script. The Contoso Account Session hosted control was created in Walkthrough 4: Display a model-driven app (Unified Interface apps) record in a session in your agent application.

  1. Sign in to Unified Service Desk Administrator.

  2. Select Hosted Controls under Basic Settings.

  3. Search for the Contoso Account Session hosted control, and select it to open the hosted control definition.

  4. Select the Related tab, and then select Events.

    Configure events for a hosted control.

  5. On the events page, select PageReady.

  6. On the PageReady page, select + Add Existing Action Calls.

  7. Type Contoso Action Call: Load Agent Script in the search box.Select action call from the list, and then select Add.

  8. Select Save.

Step 9: Add the controls to the configuration

In this step, add the action calls, agent script, hosted controls, and window navigation rule that you configured in this walkthrough to Contoso Configuration to display these controls to the user who is assigned to the configuration. Contoso Configuration was created in Walkthrough 1: Build a simple agent application for Unified Interface Apps.

Add the following to Contoso Configuration.

Control name Control type
Contoso Action Call: Create Case Action call
Contoso Action Call: Display Existing Cases Action Call
Contoso Action Call: Set Focus on Existing Cases Action Call
Contoso Action Call: Close Session Action Call
Contoso Action Call: Load Agent Script Action Call
Contoso: Welcome to Account Session Agent Script
Contoso Agent Scripting Hosted Control
Contoso new case form Hosted Control
Contoso existing cases for an account Hosted Control
Contoso New Case for Account Session Rule Window navigation rule

To add a control to the configuration:

  1. Sign in to Unified Service Desk Administrator.

  2. Select Configuration under Advanced Settings.

  3. Select Contoso Configuration to open the definition.

  4. Select the Hosted Controls, Events and Action Calls tab.

  5. Select the ellipsis (...) in the Action Calls section, and then select Add Existing Action Call. The Lookup Records pane is displayed.

  6. Type the name of the action call mentioned in the above table in the search box. The action calls are displayed in the search results. Select the record from the list, and then select Add.

  7. Select the ellipsis (...) in the Hosted Controls section, and then select Add Existing Hosted Control. The Lookup Records pane is displayed.

  8. Type the name of the hosted control mentioned in the above table in the search box. The hosted controls are displayed in the search results. Select the record from the list, and then select Add.

  9. Select the Toolbars, Window Navigation Rules and Entity Searches tab.

  10. Select the ellipsis (...) in the Window Navigation Rules section, and then select Add Existing Window Navigation Rule. The Lookup Records pane is displayed.

  11. Type the name of the Window Navigation Rule mentioned in the above table in the search box. The rule is displayed in the search results. Select the record from the list, and then select Add.

  12. Select the Session Lines, Agent Scripts and Scriptlets tab.

  13. Select the ellipsis (...) in the Agent Scripts section, and then select Add Existing Agent Script. The Lookup Records pane is displayed.

  14. Type the name of the agent script mentioned in the above table in the search box. The agent scripts are displayed in the search results. Select the record from the list, and then select Add.

  15. Select Save.

Step 10: Test the application

  1. Start the Unified Service Desk client application, and sign in to the Dynamics 365 instance where you configured Unified Service Desk by using the same user credentials that is assigned to Contoso Configuration in Walkthrough 1: Build a simple agent application for Unified Interface Apps. For information about connecting to Dataverse instance using the Unified Service Desk client application, see Connect to CRM instance using the Unified Service Desk client

  2. Select the down arrow next to the SEARCH button in the toolbar, and then select Account to display the account records from your model-driven app.

  3. Select the expander to display the left pane.

    Choose the expander in Unified Service Desk.

  4. Select on any of the account records to display the respective account information in a session. In the left pane, the Contoso: Welcome to Account Session agent script appears.

    Agent script in Unified Service Desk.

  5. In the agent script:

    1. Select New case to open a new case form with pre-populated values (in the red box) from the current account record.

    New case form using the agent script.

    1. Select Display existing cases to display the associated cases for the current account record.

    Display existing cases for an account.

    1. Select Close session to close the current session.

Conclusion

In this walkthrough, you learned how to configure a simple agent script to guide your call center agents. Unified Service Desk allows you to create more complex scripts with branching logic that contain child answers and actions. You also learned how to filter access to Unified Service Desk controls using configuration.

See also

Support for Unified Interface Apps in Unified Service Desk

Unified Interface Page (Hosted Control)

Unified Service Desk and Unified Interface Configuration Walkthroughs

Walkthrough 1: Build a simple agent application for Unified Interface Apps

Walkthrough 2: Display an external webpage in your agent application

Walkthrough 3: Display model-driven app (Unified Interface apps) records in your agent application

Walkthrough 4: Display model-driven app (Unified Interface apps) record in a session in your agent application

Walkthrough 5: Display enhanced session information by displaying session name and overview data

Walkthrough 6: Configure the Debugger hosted control in your agent application