Skip to main content

Copilot Studio integration for Microsoft Agent Framework.

Project description

Get Started with Microsoft Agent Framework Copilot Studio

Please install this package via pip:

pip install agent-framework-copilotstudio --pre

Copilot Studio Agent

The Copilot Studio agent enables integration with Microsoft Copilot Studio, allowing you to interact with published copilots through the Agent Framework.

Prerequisites

Before using the Copilot Studio agent, you need:

  1. Copilot Studio Environment: Access to a Microsoft Copilot Studio environment with a published copilot
  2. App Registration: An Azure AD App Registration with appropriate permissions for Power Platform API
  3. Environment Configuration: Set the required environment variables or pass them as parameters

Environment Variables

The following environment variables are used for configuration:

  • COPILOTSTUDIOAGENT__ENVIRONMENTID - Your Copilot Studio environment ID
  • COPILOTSTUDIOAGENT__SCHEMANAME - Your copilot's agent identifier/schema name
  • COPILOTSTUDIOAGENT__AGENTAPPID - Your App Registration client ID
  • COPILOTSTUDIOAGENT__TENANTID - Your Azure AD tenant ID

Basic Usage Example

import asyncio
from agent_framework.microsoft import CopilotStudioAgent

async def main():
    # Create agent using environment variables
    agent = CopilotStudioAgent()

    # Run a simple query
    result = await agent.run("What is the capital of France?")
    print(result)

asyncio.run(main())

Explicit Configuration Example

import asyncio
import os
from agent_framework.microsoft import CopilotStudioAgent, acquire_token
from microsoft_agents.copilotstudio.client import ConnectionSettings, CopilotClient, PowerPlatformCloud, AgentType

async def main():
    # Acquire authentication token
    token = acquire_token(
        client_id=os.environ["COPILOTSTUDIOAGENT__AGENTAPPID"],
        tenant_id=os.environ["COPILOTSTUDIOAGENT__TENANTID"]
    )

    # Create connection settings
    settings = ConnectionSettings(
        environment_id=os.environ["COPILOTSTUDIOAGENT__ENVIRONMENTID"],
        agent_identifier=os.environ["COPILOTSTUDIOAGENT__SCHEMANAME"],
        cloud=PowerPlatformCloud.PROD,
        copilot_agent_type=AgentType.PUBLISHED,
        custom_power_platform_cloud=None
    )

    # Create client and agent
    client = CopilotClient(settings=settings, token=token)
    agent = CopilotStudioAgent(client=client)

    # Run a query
    result = await agent.run("What is the capital of Italy?")
    print(result)

asyncio.run(main())

Authentication

The package uses MSAL (Microsoft Authentication Library) for authentication with interactive flows when needed. Ensure your App Registration has:

  • API Permissions: Power Platform API permissions (https://api.powerplatform.com/.default)
  • Redirect URIs: Configured appropriately for your authentication method
  • Public Client Flows: Enabled if using interactive authentication

Examples

For more comprehensive examples, see the Copilot Studio examples which demonstrate:

  • Basic non-streaming and streaming execution
  • Explicit settings and manual token acquisition
  • Different authentication patterns
  • Error handling and troubleshooting

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file agent_framework_copilotstudio-1.0.0b260304.tar.gz.

File metadata

  • Download URL: agent_framework_copilotstudio-1.0.0b260304.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_framework_copilotstudio-1.0.0b260304.tar.gz
Algorithm Hash digest
SHA256 d25b7e67d45bd39e936b9f9a9fcf0afdf838b51f9599675836e3fac6dbfc319f
MD5 5c02034721f664f75120529e4a28a158
BLAKE2b-256 cc280f2ffeee650bccd540c31ea496fba9d881dec563c1c19cd289d999817ac1

See more details on using hashes here.

File details

Details for the file agent_framework_copilotstudio-1.0.0b260304-py3-none-any.whl.

File metadata

  • Download URL: agent_framework_copilotstudio-1.0.0b260304-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agent_framework_copilotstudio-1.0.0b260304-py3-none-any.whl
Algorithm Hash digest
SHA256 befd8029c68ecea46871c2d1984ff496661f0b35671169593bb2d374183261f4
MD5 d503983753800d02b7355bb354f12574
BLAKE2b-256 2078d7c2b601d89085219af058d3c2779a5f53ececfc85a4aa33afdbf636a26c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page