Working with Copilot Studio Dynamic Chaining Plug-in Actions DateTime Parameters


Introduction

I have been spending a lot of time recently working with the Copilot Studio’s Dynamic Chaining feature using actions and plugins.

If you have not heard of the feature have a read of this Microsoft article, Use Plugin Actions in Copilot Studio (Preview)

In a nutshell, the incredibly powerful feature of dynamic chaining is that the AI can decide based on descriptions provided by the Plug-Ins which ones they should call based on the user’s request via the prompt.

The key to a successful plug-in is the way that you describe the plugin function. It needs to be in a way that the AI can understand when it should try and use that plugin. Another part of writing successful dynamic chaining plugins is spending time when describing the plugin input and output parameters. It is this aspect that I wanted to talk about today.

In this article, I wanted to show some of the things I have discovered when working with date time parameters.

In my example, we have a plugin which is running a Power Automate Flow. The ability to call a Power Automate Flow from a plugin is awesome. It allows us all sorts of freedom including allowing us to connect with different systems and make them available to the Copilot. However, one of the challenges is how we ensure that the parameters being passed into the Flow are of the right data type and format.

Let’s think about an example where we have a Power Automate that connects to a Dataverse-backed system which holds the people who are on leave. The plug-in returns an array of people who have booked leave during those two dates. The flow is set to take two parameters, StartDate and EndDate. Both parameters are strangely of type string but this works well and we can work with that in Power Automate nicely.

Our Power Automate then does a look-up against Dataverse and filters the results using the Start Date and End Date parameters.

We hook up an Action (Plugin) which calls the Flow and you try it out with the following prompt.

“I am looking to book a holiday between 1st May 2024 and 14th May 2024, is anyone else on holiday?”.

The chatbot fires up and calls the plugin as it has worked out that it needs to call our “Get people who are holiday” plugin. However, it fails because the format of the date is not right. It is expecting a date like 2024-05-01 or yyyy-mm-dd.

The error we get is this:

So, the question is how can we fix this? Well we have a couple of choices, we could put some more logic in the Flow to parse the string and turn it into the right format. We might use a parseDateTime() function but unfortunately that suffers the same fate as we had when the Flow is called and the format is not right for it to parse. Instead we could use a couple of AI Prompts using Create text with GPT and the AI Extraction. We tell the prompts to parse our Start Date and End Date and format the result as yyyy-mm-dd.

How does that work for us?

Well it works like a dream the AI prompt will format whatever is passed to us, provided it is a date into the right format and we get the results back.

Awesome!

However, what about if we wanted to do something a bit cooler and have a prompt like this.

“Is anyone on holiday in May?”.

Unfortunately, this does not work, the Plugin does not know what date to put in as the start date and end date from this prompt. It needs a bit of help.

So, what would happen if we changed the description of the parameters, Start Date and End Date in the plugin?

This was updated from

“This provides the start date for the holiday, leave or vacation.”

to

“This provides the start date for the holiday, leave or vacation.

This could be as a date or month, if it is a month then it should be the first day of the month of the current year such as 1st May 2024.”

What effect does that have?

Now suddenly we can ask the question “Who is off in May?”.

The plugin would get the parameters 1st May 2024 and 31st May 2024 used for Start Date and End Date respectively.

It is better than that, we can now say “Is anyone on holiday in Q1 2024?”

The plugin would then set the parameters to 1st January 2024 and 31st March 2024.

How cool is that?

During my experiments, I wondered why we might not need the two steps in Power Automate to convert the Start Date and End Dates into the right date-time format. Instead, what about if we use the Plugin Parameter description to do that work.

So if we update the prompt to tell it to use the format “yyyy-mm-dd” and then try it.

This worked like a charm and now the prompts were working and converting the dates into the right format and I could simplify the Flow.

What is more, I could then start asking questions like “Is anyone off on Christmas Day?” or “Is anyone off on Boxing Day?” or “Is anyone off on Star Wars Day?”

The Flow would be given the right parameters and we would see who is off.

Conclusion

So there we have it, with a bit of experimentation and thinking about the use cases there is a lot of power in the Plugin Parameter description. With the description we can get the system to do the hard work of formatting data into the structure that you need.

I hope that you found this useful and let us know how you get on.

What and Why Would You Want To Build a Custom Copilot?


Introduction

In my recent blog series about building a Teams AI Library-based Custom Copilot, I realised that I had not really talked about what a Custom Copilot is and why you might want to build one. Simon Sinek, would not be impressed!

So, in this blog post, I start with the why. So, why would you want to build a Custom Copilot? Plus I suppose I better explain what they are.

I talked about these aspects in a recent session I did for Chirag at M365 UK, called Custom Copilot The Options so you are welcome to watch that instead.

Session 2 (54:45) : Custom Copilots in Microsoft 365 – The Options – Simon Doy MVP

Anyway, here we go.

Why would you want to build a Custom Copilot?

So, why would you want to build a Custom Copilot and what are they?

So, a Custom Copilot is a Generative AI Chatbot that is specific in what it provides, it might cover a particular role or task and is not generic. For example, you might have a Copilot for HR which provides information for employees on HR matters.

Its power is in that it is specific. However, that can also be its downfall because it is specific and only knows information about a topic.

A Custom Copilot need not only be an information gatherer, it may also be a way to perform actions for example, the Copilot for HR might allow someone to submit a form for changing personal details for example.

So, now we have explained what a Custom Copilot is, then let’s explain why you might want to build one. As we mentioned they are great when you need to build something that provides a specific purpose or role. One of the challenges with broader Copilots, for example, Copilot for Microsoft 365 is that they can access a lot of data and information and that makes it hard for the LLM behind the Copilot to know what is important. By having a more specific dataset and providing a particular need the Copilot can be built with that in mind.

All these capabilities make the Copilot easier to use and it will likely be better at providing more relevant results. Additionally, for organisations looking to have these built, the risk is reduced of them failing. This is because their scope is smaller, so testing and getting feedback on how they perform is quicker and more targeted.

Custom Copilots can be made available in Microsoft Teams and Microsoft SharePoint, actually, they can be delivered through a huge number of different channels via the Microsoft Bot Service and Microsoft Copilot Studio.

We want to build one, where should we start looking?

Well of course you can come and chat with us at iThink 365.

However, there are lots of resources out there. I would recommend watching the Microsoft 365 Development Community calls and reading these resources found on Microsoft Learn.

Building your custom copilot on Teams with the Teams AI Library

Create copilots with Microsoft Copilot Studio – Training | Microsoft Learn

Of course, have a look at my blog post on Building Custom Copilots with Teams AI Library and Azure AI Search.

What do you need to think about?

To be honest this area is moving quickly and changing all the time. The technology behind the Custom Copilots is very new and uses GPT models such as GPT 3.5 and GPT 4.

The patterns that are used for knowledge management-based Custom Copilots need a lot of testing and development as whether they are fit for your purpose depends on how the data is structured, chunked up, and put into the search index. There are a lot of variables that need to be managed here and tried out to give the users the results that they expect and help them get their jobs done.

However, it should not be underestimated the amount of time this will take and the tweaking that is required.

Conclusion

Thanks for reading this post and I look forward to hearing how you get on with your Custom Copilot journey.

Please feel free to reach out if you need support on your journey.