Power Community

Power Community

Using Expression Builder to Open Agent Scripts Dynamically

In this post, we will look at the Customer Service workspace functionality to open Agent Scripts dynamically based on criteria using the Expression Builder.

First, let’s look at setting this up. Go to the Customer Service workspace admin app and select Session Templates, then open your session template:

We have a session template called Test Case Template, which will open when a case is initiated in CSw:

There are 2 agent scripts assigned to this session template:

  • Agent script session template
  • Agent script session template 2

The steps in each agent script look different, as you would expect.

Case trial agent script has:

Case trial agent script 2 has:

Now, to open these scripts dynamically, select Enable build expression, then click the Build Expression button:

This opens like below. Expand the Condition:

You will see something like this. Here we can define the condition and then which agent script to open given the condition:

Let’s go through an example. A case has a field called “Subject”. Let’s say if the subject of a case equals “auto-drip” then we want to open “Case trial agent script 2”:

We can get the name of the field through a query (easy way to build this would be through Dataverse REST Builder tool in XrmToolbox):

And this will give us the fieldname:

Now we can paste this into our expression like below. We will need to wrap it with $anchor. like below:

${anchor._subjectid_value@OData.Community.Display.V1.FormattedValue}

For the if true, we’re going to select an agent script connector:

Then set default agent script:

And let’s select Case trial agent script 2:

Repeat for if false, and we will select Case trial agent script 1:

Note the “set default agent script” title in blue above, you can call this anything meaningful.

Then save and close, and we can try this out. Refresh the Customer Service workspace app if you already had it open. Let’s select an “auto-drip” subject case. We see “case trial agent script 2” opens:

And if we open a non auto-drip case such as water-supply, we see the case trial agent script opens:

We are now opening our agent scripts dynamically.

Let’s now use OData to query in our Expression Builder to see another way of dynamically opening agent scripts. The OData queries are in the format below per the Microsoft documentation:

In our case, let’s use the title of the case as an example. Our query is below. Note the format:

${$odata.incident.title.?$filter=incidentid eq ‘${anchor.incidentid}’&$select=title}

Now let’s change our query to below, and save and close:

We see our agent script opens as expected:

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.

 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET’S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

ABOUT CARL DE SOUZA
image

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Embed Python Visuals in Power BI Desktop – Quick Review

Hi Folks, This post is all about embedding Python visuals in Power BI, you will need to install the respective...

More Articles Like This

- Advertisement -spot_img