β οΈ DISCLAIMER: This repository is provided for demonstration and educational purposes only. It is not an officially supported Microsoft product. Use of this code is at your own risk. Microsoft makes no warranties, express or implied, and assumes no liability for any issues arising from the use of this repository in production environments.
A Power Apps Component Framework (PCF) control that enables rich chat experiences with Microsoft Copilot Studio, featuring voice input/output and adaptive card support.
- β Modern Chat UI - Clean, responsive chat interface built with Fluent Design
- β Voice Input - Speech-to-text using browser Web Speech API or Azure Speech Services
- β Voice Output - Text-to-speech with Azure Neural Voices or OpenAI TTS
- β Adaptive Cards - Support for rich interactive cards from Copilot Studio
- β Mobile Support - Works on iOS, Android, and desktop browsers
- β Direct Line Integration - Connects to Copilot Studio via Direct Line API
- β Driving Mode - Hands-free operation for field workers (Beta)
- β Multi-Language Support - 34 languages with native Azure Neural voices (Beta)
- β Admin/Debug Mode - In-app debug logging panel for troubleshooting (Beta)
- Power Apps Environment with PCF controls enabled
- Microsoft Copilot Studio bot with Web channel configured
- Power Platform CLI (
pac) installed - Node.js (v16 or higher) and npm
- .NET Framework 4.8.1 or higher
- Azure Speech Service (for premium neural voices)
- Azure Subscription (if using Azure Speech Service)
git clone https://github.com/microsoft/Copilot-Studio-Chat-PCF-Control-with-Voice.git
cd Copilot-Studio-Chat-PCF-Control-with-Voicecd CopilotChatDirectLine
npm install# Build the PCF control
npm run build
# Or use Power Platform CLI
pac pcf push --publisher-prefix YOUR_PREFIX- Open your Copilot Studio bot
- Go to Settings > Channels
- Add Web channel (if not already added)
- Copy the Direct Line Secret from Channel Security
- Open Power Apps Studio
- Create or open a Canvas App
- Go to Insert > Get more components > Code components
- Select Copilot Studio Chat control
- Add control to your screen
- Important: Set layout properties (see below)
- Configure properties:
- DirectLineSecret: Your Direct Line secret
- DirectLineEndpoint: Leave default (
https://directline.botframework.com/v3/directline)
For optimal display, configure these layout properties on the control:
| Property | Setting |
|---|---|
| Flexible height | β On |
| Align in container | Custom β Stretch |
This ensures the chat control:
- Fills its container properly
- Responds to dynamic content height (messages, cards)
- Works correctly in responsive layouts
For detailed deployment instructions, see the Deployment Guide.
The control supports Azure Speech Services (for premium neural voices) and Azure OpenAI (for natural-sounding TTS). You can provision both resources with a single click:
| Resource | Type | Purpose |
|---|---|---|
{prefix}-speech |
Azure Speech Services | Premium neural voice TTS and speech-to-text |
{prefix}-openai |
Azure OpenAI | Natural OpenAI TTS voices (echo, alloy, nova, etc.) |
| Model deployment | OpenAI model (gpt-4o-mini default) | Language model for TTS and chat capabilities |
- Click the Deploy to Azure button above
- Sign in to your Azure subscription
- Fill in the parameters:
- Resource Prefix: A unique name prefix (e.g.,
contoso) β createscontoso-speechandcontoso-openai - Location: Region for Speech Services (e.g.,
eastus) - OpenAI Location: Region for Azure OpenAI (e.g.,
eastus2) - OpenAI Model: Choose model (default:
gpt-4o-mini) - Speech Service SKU:
F0(free tier) orS0(standard)
- Resource Prefix: A unique name prefix (e.g.,
- Click Review + Create, then Create
- Wait for deployment to complete (~2-3 minutes)
- Go to Outputs tab and copy these values into your Dynamics 365 environment variables:
| Output | Environment Variable |
|---|---|
speechKey |
bw_SpeechKey |
speechRegion |
bw_SpeechRegion |
openAIEndpoint |
bw_OpenAIEndpoint |
openAIKey |
bw_OpenAIKey |
openAIDeploymentName |
bw_OpenAIDeployment |
If you prefer to create resources manually:
- Create an Azure Speech Service resource in the Azure Portal
- Copy your KEY and REGION from Keys and Endpoint
- Set environment variables:
- bw_SpeechKey: Your Speech Service key
- bw_SpeechRegion: Your region code (e.g.,
eastus)
- Create an Azure OpenAI resource with a model deployed
- Set environment variables:
- bw_OpenAIEndpoint: Your Azure OpenAI endpoint URL
- bw_OpenAIKey: Your Azure OpenAI API key
- bw_OpenAIDeployment: Deployment name (default:
gpt-4o-mini)
| Profile | Voice | Style | Best For |
|---|---|---|---|
openai-echo |
Echo | Warm, conversational | Default - friendly interactions |
openai-alloy |
Alloy | Neutral, balanced | General purpose |
openai-fable |
Fable | Expressive, narrative | Storytelling |
openai-onyx |
Onyx | Deep, authoritative | Professional settings |
openai-nova |
Nova | Warm, friendly | Customer service |
openai-shimmer |
Shimmer | Clear, optimistic | Upbeat interactions |
| Profile | Voice | Style | Best For |
|---|---|---|---|
jenny-friendly |
Jenny | Friendly | Default, warm conversations |
jenny-customerservice |
Jenny | Customer Service | Professional support |
aria-customerservice |
Aria | Customer Service | Business interactions |
aria-empathetic |
Aria | Empathetic | Sensitive topics |
guy-friendly |
Guy | Friendly | Male voice option |
davis-chat |
Davis | Chat | Casual conversations |
sara-friendly |
Sara | Friendly | Alternative female voice |
The Beta control supports 34 languages for both speech recognition and text-to-speech. Users can select their preferred language from the Settings panel.
| Region | Languages |
|---|---|
| Americas | English (US, CA), Spanish (CO, MX, AR, CL, PE, US), Portuguese (BR), French (CA) |
| Europe | English (UK), Spanish (ES), French (FR), German, Italian, Portuguese (PT), Dutch, Polish, Swedish, Norwegian, Danish, Finnish, Russian, Ukrainian, Czech, Greek |
| Asia | Chinese (Simplified, Traditional, HK), Japanese, Korean, Hindi, Thai, Vietnamese, Indonesian, Malay, Filipino |
| Middle East | Arabic (SA, EG, AE), Hebrew, Turkish |
| Africa | Afrikaans, Swahili |
- User's saved preference - Persisted in localStorage from Settings
- Admin-configured default - Set via
DefaultLanguageproperty - Browser auto-detection - Falls back to browser locale
Set a default language via the control property:
- DefaultLanguage: BCP-47 language code (e.g.,
en-US,es-MX,fr-FR)
The Beta control includes an Admin Mode toggle that enables a debug logging panel for troubleshooting.
- π Debug Panel - Full-screen overlay showing timestamped log entries
- π Log Categories - Filter by level (info, warn, error, debug) or category (speech, audio, console)
- π§ Email Logs - One-click export to email for support escalation
- π Copy to Clipboard - Export formatted logs for pasting
- π Auto-capture - Intercepts all console.log/warn/error calls
- πΎ Persistent - Stores up to 500 log entries
Option 1: Settings Panel (User Toggle)
- Open the Settings panel (βοΈ button)
- Scroll to the bottom
- Toggle π οΈ Admin Mode on
- A debug button (π) appears in the toolbar
Option 2: Admin Property (Pre-configured)
- Set
EnableDebugLogproperty toYesin the control configuration
The debug panel can capture sensitive information. Use only for development/troubleshooting.
The following control properties contain sensitive credentials that are visible in the Power Apps maker portal:
| Property | Description |
|---|---|
DirectLineSecret |
Direct Line Secret from Copilot Studio |
SpeechKey |
Azure Speech Service subscription key |
OpenAIKey |
Azure OpenAI API key |
- Environment Variables - Store secrets as Power Platform Environment Variables, optionally linked to Azure Key Vault
- Dataverse Secure Columns - Store secrets in Dataverse columns with column-level security
- Role-Based Access - Limit maker portal access to authorized administrators only
β οΈ Property descriptions now include π SENSITIVE warnings to remind administrators.
βββ CopilotChatDirectLine/ # PCF Control Source
β βββ CopilotChatBeta/ # Beta version (latest features)
β βββ CopilotChatGA/ # General Availability (stable)
β βββ package.json
β
βββ CopilotChatPCFControl/ # Solution Package
β βββ src/
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
See CONTRIBUTING.md for detailed contribution guidelines.
See SECURITY.md for information about reporting security vulnerabilities.
For support options, see SUPPORT.md.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
This project is licensed under the MIT License - see the LICENSE file for details.