Goal : Interact with Magic xpi using copilot prompt in natural language via a specialized declarative agent

Prerequisites :
- Microsoft tenant with your admin user or user that have enough rights to publish and allow custom upload apps
- Copilot For Microsoft 365 License (1 user for test)
- Microsoft 365 Business Basic License (1 user for test)
- Visual Code with Teams Toolkit plugin installed
1/ Open your Magic xpi Studio
Create an HTTP trigger with 1 method (GetOrderDetail) with 1 argument (OrderNum)

2/ Design a Flow that retrieves the detail of the order according to OrderNum parameter and answers a JSON message with the related information
(*) In my case, i’m retrieving the detail of the order from a Prestashop system via MySQL Database

My step mapper (get Order det. from Prestashop) should be like this (for my case)


3/ Build the Json response

4/ Build and start your project.
5/ Check with Postman that you can trigger the Magic xpi Flow by passing the orderNum

5/ Start your Visual Code and install the Teams Toolkit plugin
Menu: View=>Extensions =>enter Teams Toolkit

6/ After installation, sign on https://admin.teams.microsoft.com
Allow Upload Custom App

Go back to Visual Code, choose on the left menu Teams Toolkit

Sign in with your admin user on the menu Accounts.
!! You should check that these 2 options below are enabled:
- Custom App Upload Enabled
- Copilot Access Enabled
(*) Copilot Access Enabled can be delayed to be activated (24h)
7/ At this point, you need to get a Magic xpi Yaml file from your endpoints
You can use Postman for that.
8/ Go Back to your visual code
Choose TeamsToolkit menu and create a Declarative Agent

Choose Addplugin=>Start With OpenApi Description Document>browser and give your yaml file
Make your changes in the project.
You can use snippet UI (adaptivecards.io) to handle the Magic xpi JSON response.
9/ Provision the project and if it’s ok then Publish your agent (apps)
Menu LIFECYCLE => Provision



10/ Go to your teams admin portal
You must approve the pending custom apps (if it’s newly created you should see 1 in Submitted custom apps)
The first time, App Status should be « Blocked », you must have « Allowed »


Choose Publish by clicking on the agent below

7/ Go to your Copilot prompt
Select You agent on the Right pane
On the prompt: you can ask your question in french or english to get the order total and more


The first time you ask your question, you should receive this message related to your agent and you have to authorize (« Always » or « Once »)

15/ You can handle exception in the Magic process if the order is not found

or if there is no delivery date then, you can get :

8/ If you enter a sentence without giving the Order Number then Copilot will ask you to pass it

9/ You can ask for the order detail as well
Ask for the total first

then ask for the detail (you don’t need to enter the order number) as we are in the same context

(*) You can bind the magic xpi json array to a ColumnSet in the adaptivecard.
10/ Each time you enter an Order Number in the prompt, a Magic xpi flow is triggered receiving the order num

10/ With this architecture, you can design as many flows as you want in Magic xpi (with any Business rules), expose them in the copilot agent (via yaml file) and interact in a natural language.
Don’t hesitate to contact me if you are interested to implement it.