Please note - S2S is not currently supported for Copilot Studio. It is in active development, and once there is an ETA we will update this notice.
To set up this sample, you will need the following:
- Python version 3.10 or higher
- An Agent Created in Microsoft Copilot Studio or access to an existing Agent.
- Ability to Create an Application Identity in Azure for a Public Client/Native App Registration Or access to an existing Public Client/Native App registration with the
CopilotStudio.Copilots.InvokeAPI Permission assigned.
- Python version 3.10 or higher
- dev tunnel (for local development)
- An Agent created in Microsoft CopilotStudio or access to an existing Agent.
- Ability to create an Application Identity in Azure for a public client/native App Registration or access to an existing one with the
CopilotStudio.Copilots.InvokeAPI permission assigned.
The CopilotStudio Client requires a User Token to operate. For this sample, we are using a user interactive flow to get the user token for the application ID created above. Other flows are allowed.
Important
The token is cached in the user machine in .local_token_cache.json
- Create an Agent in Copilot Studio
- Publish your newly created Copilot
- Go to Settings => Advanced => Metadata and copy the following values, You will need them later:
- Schema name
- Environment Id
This step will require permissions to create application identities in your Azure tenant. For this sample, you will create a Native Client Application Identity, which does not have secrets.
- Open https://portal.azure.com
- Navigate to Entra Id
- Create a new App Registration in Entra ID
- Provide a Name
- Choose "Accounts in this organization directory only"
- In the "Select a Platform" list, Choose "Public Client/native (mobile & desktop)
- In the Redirect URI url box, type in
http://localhost(note: use HTTP, not HTTPS) - Then click register.
- In your newly created application
- On the Overview page, Note down for use later when configuring the example application:
- The Application (client) ID
- The Directory (tenant) ID
- Go to API Permissions in
Managesection - Click Add Permission
- In the side panel that appears, Click the tab
API's my organization uses - Search for
Power Platform API.- If you do not see
Power Platform APIsee the note at the bottom of this section.
- If you do not see
- In the Delegated permissions list, choose
CopilotStudioand CheckCopilotStudio.Copilots.Invoke - Click
Add permissions
- In the side panel that appears, Click the tab
- Click Add Permission again
- Click on
Microsoft Graph. - In the Delegated permissions list, choose 'User' and Check
User.Read - Click
Add permissions
- Click on
- (Optional) Click
Grant Admin consent for copilotsdk
- On the Overview page, Note down for use later when configuring the example application:
Tip
If you do not see Power Platform API in the list of API's your organization uses, you need to add the Power Platform API to your tenant. To do that, goto Power Platform API Authentication and follow the instructions on Step 2 to add the Power Platform Admin API to your Tenant
With the above information, you can now run the client CopilotStudioClient sample.
- Open the
env.TEMPLATEfile and rename it to.env. - Configure the values based on what was recorded during the setup phase.
COPILOTSTUDIOAGENT__ENVIRONMENTID="" # Environment ID of environment with the CopilotStudio App.
COPILOTSTUDIOAGENT__SCHEMANAME="" # Schema Name of the Copilot to use
COPILOTSTUDIOAGENT__TENANTID="" # Tenant ID of the App Registration used to login, this should be in the same tenant as the Copilot.
COPILOTSTUDIOAGENT__AGENTAPPID="" # App ID of the App Registration used to login, this should be in the same tenant as the CopilotStudio environment.-
(Optional but recommended) Set up virtual environment and activate it.
-
After installing the dependencies with
pip install -r requirements.txt, run the CopilotStudioClient sample using
python -m src.mainThis should challenge you to login and connect to the Copilot Studio Hosted agent, allowing you to communicate via a console interface.
For more information on logging configuration, see the logging section in the Quickstart Agent sample README.