Sample Declarative Agent for Microsoft 365 Copilot using the public random user generator API at https://randomuser.me/.
This tutorial uses the Teams Toolkit and Visual Studio Code to build the sample agent, if you have not used the Teams Toolkit before I recomend completing this official tutorial first Create declarative agents using Teams Toolkit.
I am a member of the Microsoft Copilot team working on the Declarative Agent platform and I created this sample app to explore and test building an agent that retrieves data from external APIs (also known as actions).
My first step was finding a suitable API. At Apipheny, a site offering a collection of free public APIs, I discovered a random user data generator randomuser.me). This open-source API provides details about a fictional user, including gender, name, email, and address—a “Lorem Ipsum” for user data.
The creators of Random User don’t provide an OpenAPI specification file, but you can use Copilot to generate one from the available documentation. Try this prompt:
Can you create an open API specification from this web page https://randomuser.me/documentation
Next ask Copilot to save it as a YAML file
In the Teams Toolkit, select Create New App, select Agent, Declarative Agent, Add Plugin, and then select “Start with an OpenAPI Description Document”, and browse to the YAML file. The Teams Toolkit will build the files needed for a declarative agent. The files you want to edit to add the functionality are in the /appPackage.
The only 2 files you probably need to modify are instructions.txt (where you put the LLM instructions for what the agent should do) and declarativeAgent.json (where you can add the conversation starters) and other configurations.
When you're ready, select Provision to validate the agent, package it into a zip file, and deploy it.