Configure scripts and macros

Completed

Scripts and macros work together in the productivity pane to guide representatives through a conversation and automate the mechanical parts of each interaction. Scripts tell representatives what to do, and macros do it for them.

Understand scripts

A script is a structured set of sequential steps that guides a representative through an interaction. Each step tells them what action to take: greet the customer, verify their account, send a knowledge article link, update the case status. Scripts appear in the Scripts section of the productivity pane, so representatives can follow them without losing focus on the conversation.

Scripts reduce human error, enforce process adherence, and lower average handling time. They're especially useful for complex conversation types—new-issue intake, compliance-sensitive workflows, escalation scenarios, where missing a step has real consequences.

Screenshot of the productivity pane in Copilot Service workspace showing a script with steps such as Greet customer, Verify customer, and Search and share article.

Create a script

  1. In Copilot Service admin center, navigate to Support experience > Productivity.
  2. Select Manage for Scripts, then select New.
  3. Enter the following:
Field Description
Name The display name for the script.
Unique Name A unique identifier in the format <prefix>_<name>. The prefix must be 3–8 alphanumeric characters with an underscore separating it from the name.
Language The script language. Only languages enabled in Microsoft Dataverse appear.
Description An optional description for your reference.
  1. Select Save. The Script steps section appears.

Add script steps

Each step defines a single action in the script. To add a step, select New Script step in the Script steps section, then configure the following:

Field Description
Name The label shown to the representative at runtime. Supports slugs for dynamic content—for example, Hi ${customerName}.
Unique Name A unique identifier in <prefix>_<name> format.
Order The sequence number for the step.
Action Type Select Text instruction, Macro, or Script.
Text instruction (Text type only.) The text the representative reads and acts on. Supports slugs and OData queries.
Target macro (Macro type only.) The macro to run when the representative triggers this step.
Target script (Script type only.) A nested script to load.

Select Save and Close when done, then save the script.

Screenshot of a script configuration form in Copilot Service admin center showing the Name, Unique Name, Language, and Description fields alongside the script steps list with Text, Macro, and Script action types.

Use slugs to make scripts dynamic

Slugs are session context variables that resolve to real values at runtime. You can use them anywhere in a script step's Name or Text instruction fields to personalize content with information from the current session.

Session context is populated from two sources:

  • Case sessions: the anchor tab populates variables like ${anchor.ticketnumber}, ${anchor.title}, and ${anchor._customerid_value@OData.Community.Display.V1.FormattedValue} with values from the case record.
  • Conversation sessions: the channel provider populates variables like ${customerName}, ${Email}, and ${queueId} with values from the incoming interaction.

You can also retrieve values from related records using an OData query:

${$odata.contact.emailaddress1.?$filter=contactid eq '{anchor._customerid_value}'}

This example retrieves the email address from the customer contact record linked to the current case. OData queries let scripts surface information that isn't directly on the anchor record, without requiring the representative to open a second tab.

Associate a script with a session template

A script doesn't display to representatives automatically — you need to associate it with a session template. This controls which scripts are available for a given session type.

  1. Navigate to Support experience > Workspaces, then select Manage for Session templates.
  2. Select the session template—for example, Chat - Default Session.
  3. Select the Scripts tab, then select Add Existing script.
  4. Search for the script, select it, and select Add, then Save.

Screenshot of a session template's Agent scripts tab in Copilot Service admin center showing two associated scripts in a list.

To control which script loads by default when a representative accepts a session, use the Expression builder. In the Scripts tab of the session template, set Enable build expression to Yes, select Build Expression, and define conditions based on session context variables. This way, a queue-specific script loads automatically for that queue's conversations without the representative having to select it manually.

Configure macros

A macro is a set of automated actions that run in sequence when triggered. Representatives can run macros from the productivity pane, or you can call them from within a script step using the Macro action type. This combination, a script step that fires an action, is how you create a guided experience where each step both instructs and acts.

To create a macro:

  1. Navigate to Support experience > Productivity, then select Manage for Macros.
  2. Select New, enter a name and description.
  3. Add Start macro execution as the first step—this is required for every macro.
  4. Add subsequent steps using one of the action categories described next.

Macro action categories

Macros support four categories of actions, which you mix and match to build your automation:

Category What it does
Productivity automation Opens or updates records, opens views, resolves cases, searches the knowledge base, clones records, opens email templates, fills form fields, sets and retrieves session context variables, and supports integration with external web pages and applications.
Session connector Gets tab IDs, refreshes tabs, opens tab templates, sets focus to a tab, refreshes session context, and passes tab IDs between steps.
Omnichannel connector Links and unlinks Dynamics 365 records (accounts, contacts, cases) to the current conversation.
Flow connector Triggers a Power Automate flow.

Screenshot of the Omnichannel Connector action picker in the macro designer showing options to send a KB article in chat, link a record to the conversation, and unlink a record from the conversation.

Macros run in the context of the current session and have access to the same slug values as scripts. A single macro can open the customer's account record, fill in the resolution notes from the session context, and save — without the representative touching the form.

Tip

Use the Productivity automation action to auto-fill form fields with slug values. This is particularly useful for post-conversation wrap-up tasks where the same fields need the same data every time.