{"id":13514,"date":"2023-04-11T08:00:15","date_gmt":"2023-04-11T15:00:15","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/?p=13514"},"modified":"2023-08-22T17:00:55","modified_gmt":"2023-08-23T00:00:55","slug":"deploy-your-chatgpt-based-model-securely-using-microsoft-teams-power-virtual-agent-and-azure-openai","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/deploy-your-chatgpt-based-model-securely-using-microsoft-teams-power-virtual-agent-and-azure-openai\/","title":{"rendered":"Deploy your ChatGPT based model securely using Microsoft Teams, Power Virtual Agent and Azure OpenAI"},"content":{"rendered":"<p>This article describes different options to implement the ChatGPT (gpt-35-turbo) model of Azure OpenAI in Microsoft Teams. Due to the limited availability of services \u2013 in public or gated previews \u2013 this content is meant for people that need to explore this technology, understand the use-cases and how to make it available to their users in a safe and secure way via Microsoft Teams. Even if access to those services may be limited at the time of writing, the concepts and design patterns documented here should guide the reader through different options.<\/p>\n<h2>What makes generative AI different from other technologies?<\/h2>\n<p>Artificial Intelligence (AI) and its large language models have been getting quite a lot of attention lately, and it&#8217;s easy to understand why. With the latest breakthroughs in AI, we are now seeing more accurate, adaptable, and intelligent AI systems that can solve more complex problems.<\/p>\n<p>ChatGPT developed by OpenAI, specifically, has generated a lot of excitement and high expectation as it can generate human-like text responses based on given prompts, becoming increasingly popular in the corporate world as a tool for automating routine tasks or answering customer queries.<\/p>\n<p>Based on this analysis from Statista and other observers, ChatGPT on OpenAI reached their first million users after only five days compared to 2.5 months for Instagram that was the service showing the fastest adoption before that. Source: <a href=\"https:\/\/www.statista.com\/chart\/29174\/time-to-one-million-users\/\">Chart: ChatGPT Sprints to One Million Users | Statista<\/a><\/p>\n<p>However, it is important to remember that with the many benefits that AI brings, there are also potential risks and challenges that must be taken into consideration, particularly potential data breaches and privacy violations. Some companies shared their concerns about employees posting sensitive information to chat-based AI services and issued guidelines on how to use these services.<\/p>\n<p>As a Customer Success Manager, I\u2019ve seen several enterprise customers exploring solutions to give their employees access to the conversational AI in a more controlled and safer environment for the company. This is how I designed this solution, called MyAssist, based on Microsoft services: Teams, Power Virtual Agent and Azure OpenAI. MyAssist is deployed to employees as an application for Microsoft Teams.<\/p>\n<p>If you plan to deliver a bot service based on generative AI, I encourage the reader to review <a href=\"https:\/\/learn.microsoft.com\/en-us\/legal\/cognitive-services\/openai\/transparency-note\">this page on responsible AI<\/a> to understand how this technology works, what you can expect from this type of services, what are the limits and educate users on how to prompt practices and practice for responsible use.<\/p>\n<p>&nbsp;<\/p>\n<h2>How does this solution help mitigate the company\u2019s concerns?<\/h2>\n<p><strong>Microsoft Teams<\/strong> offers a variety of security and compliance services to protect your data and help you meet regulatory requirements. These services include data encryption, role-based access control, multi-factor authentication, and compliance with industry standards and regulations. All chat messages (questions and answers) between a user and a bot application queried from Teams are handled as any other chat messages between users in Teams. Companies that implemented Security &amp; Compliance service like Microsoft Purview via <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoft-365\/compliance\/ediscovery\">eDiscovery<\/a>, <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoft-365\/compliance\/sensitive-information-type-learn-about\">sensitive information types<\/a>, <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoft-365\/compliance\/retention\">retention policies<\/a>, or other services like <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoftteams\/export-teams-content\">Teams Export APIs<\/a> or <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoft-365\/security\/office-365-security\/safe-links-about\">Safe Links for Teams<\/a>, and many others, can take advantage of these solutions for chat messages with bots in Teams.<\/p>\n<p><strong>Power Virtual Agents<\/strong> lets you create powerful AI-powered chatbots for a range of requests\u2014from providing simple answers to common questions to resolve issues requiring complex conversations. It is by far the fastest path to delivering a chat bot with built-in integration and publishing in Teams, including enabling authentication and user SSO in a click of a button. Power Virtual Agent has a large <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-virtual-agents\/admin-certification\">compliance offer<\/a> that includes HIPAA coverage, FedRamp, SOC, MTCS, CSA and more. PVA instances are deployed in your own <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-platform\/admin\/environments-overview\">Power Platform environment<\/a> to satisfy your security, user access, governance, data-loss prevention rules, authorized connectors, data residency requirements and more. Last, you can download and view up to seven days of conversation transcript sessions in PVA from the past 30 days (by default) and configure the <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-virtual-agents\/analytics-sessions#change-the-default-period-of-session-transcript-retention\">transcript retention<\/a> to you needs.<\/p>\n<p><strong>Azure OpenAI Service<\/strong> gives customers advanced language AI with OpenAI GPT-4, GPT-3, Codex, and DALL-E models with the security and enterprise promise of Azure. Azure OpenAI co-develops the APIs with OpenAI, ensuring compatibility and a smooth transition from one to the other. With Azure OpenAI, customers get the security capabilities of Microsoft Azure while running the same models as OpenAI. Azure OpenAI offers private networking, regional availability, and responsible AI content filtering. With Azure OpenAI Service, customer can decide the location of the service, based on <a href=\"https:\/\/azure.microsoft.com\/en-us\/explore\/global-infrastructure\/products-by-region\/?products=cognitive-services\">Azure regions and service availability<\/a>, and review <a href=\"https:\/\/learn.microsoft.com\/en-us\/legal\/cognitive-services\/openai\/data-privacy\">Microsoft data, privacy, and security statements<\/a> on how data provided by you to the Azure OpenAI Service is processed, used, and stored.<\/p>\n<p>By combining Microsoft Teams, Power Virtual Agent and Azure OpenAI Service, enterprises can provide a modern conversational AI experience, or any other generative AI model available on the Microsoft platform, that employees are so enthusiasts to use in a more controlled and secure way.<\/p>\n<p>&nbsp;<\/p>\n<h2>Technical requirements<\/h2>\n<p>All the services used in this article are still in (limited) public preview. It\u2019s important to remind the readers that features in preview have limitations:<\/p>\n<ul>\n<li>Preview features <strong>aren\u2019t meant for production use <\/strong>and may have restricted functionality.<\/li>\n<li>These features are available before an official release so that customers can get early access and provide feedback.<\/li>\n<li>These capabilities are in the process of rolling out and may not be available in your region yet.<\/li>\n<li>These capabilities may be subject to usage limits or capacity throttling.<\/li>\n<\/ul>\n<p>For more information, go to our\u00a0<a href=\"https:\/\/go.microsoft.com\/fwlink\/?linkid=2189520\">preview terms<\/a>.<\/p>\n<p>How to access these services:<\/p>\n<ul>\n<li><strong>Microsoft Teams<\/strong> \u2013 You can <a href=\"https:\/\/www.microsoft.com\/en-us\/microsoft-teams\/\">sign-up for Microsoft Teams<\/a> if you don\u2019t have a subscription already. Please check <a href=\"https:\/\/learn.microsoft.com\/en-us\/microsoftteams\/new-teams-desktop-admin?tabs=teams-admin-center#apps\">known issues<\/a> with custom apps installation if you\u2019re using the new Teams.<\/li>\n<li><strong>Power Virtual Agent (preview) <\/strong>\u2013 If you don\u2019t plan to deploy your bot in production, we recommend using the preview version of PVA that supports the new unified authoring canvas and Adaptive Cards format \u2013 The preview version is not mandatory but provides a better user experience to build the dialogs. Supported language is English only. You can get a <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-virtual-agents\/sign-up-individual\">30-days trial license for Power Virtual Agent<\/a> if you don\u2019t have a license already.<\/li>\n<li><strong>AI Builder for Power Automate (preview)<\/strong> \u2013 This option provides a built-in connector for Power Automate to query ChatGPT on Azure OpenAI Service \u2013 This capability is in gated preview, and you&#8217;ll need to apply for consideration to take part in the trial. To apply, go to <a href=\"https:\/\/forms.office.com\/Pages\/ResponsePage.aspx?id=v4j5cvGGr0GRqy180BHbR2LogRPRiTJDo1Rd8KnmcFRUMzlLTDZVQlJKSzNIWkVCMzE0VDFYVzk2QS4u\">Limited preview request<\/a>.<\/li>\n<li><strong>Azure OpenAI Service (preview) <\/strong>\u2013 You need an Azure subscription as well as an access granted to the models gpt-35-turbo or gpt-4 \u2013 These models are currently available in limited US regions. Follow <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cognitive-services\/openai\/chatgpt-quickstart\">this link<\/a> to review the prerequisites and request access. You can get an Azure subscription for free on <a href=\"https:\/\/azure.microsoft.com\/free\/cognitive-services?azure-portal=true\">this link<\/a>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Design patterns<\/h2>\n<p>In this post, I document <strong>option #2<\/strong> that combines PVA and Azure OpenAI Service. Option #2 provides a good trade-off between the simplicity to deploy a bot in Teams via PVA, as opposed to a full development using the Azure bot service, and better control over the AI generative models via Azure OpenAI Service, as opposed to the AI Builder connector for ChatGPT on Azure OpenAI Service.<\/p>\n<ul>\n<li>If you want to explore <strong>option #1<\/strong>, I recommend reading this documentation &#8211; <a href=\"https:\/\/learn.microsoft.com\/en-us\/ai-builder\/azure-openai-model-pauto\">Use your Azure OpenAI Service model in Power Automate (preview) | Microsoft Learn<\/a><\/li>\n<li>If you want to explore <strong>option #3<\/strong>, I recommend this GitHub repository from my colleague Freist Li &#8211; <a href=\"https:\/\/github.com\/freistli\/rootbot\">GitHub &#8211; freistli\/rootbot: Bot App integrated with several LLMs services (ChatGPT, GPT-3, DALL-E) from OpenAI and Azure OpenAI.<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-1.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-13515\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-1-1024x647.png\" alt=\"ChatGPT design pattern options with Power Platform and Azure.\" width=\"640\" height=\"404\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-1-1024x647.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-1-300x189.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-1-768x485.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-1.png 1039w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>Let\u2019s make it!<\/h2>\n<h3>Step 1 \u2013 Create your instance of Power Virtual Agent<\/h3>\n<ol>\n<li>Login to <a href=\"https:\/\/powerva.microsoft.com\">https:\/\/powerva.microsoft.com<\/a><\/li>\n<li>If this is you first deployment of Power Virtual Agent, you\u2019ll be asked to choose your country\/region \u2013 Make sure you select a location that is compliant with your organization\u2019s compliance and geographic boundaries &#8211; <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-virtual-agents\/data-location\">Regional settings and data locations &#8211; Power Virtual Agents | Microsoft Learn<\/a><\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-13544 size-full\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-2.png\" alt=\"How to choose your country\/region if this is you first deployment of Power Virtual Agent.\" width=\"794\" height=\"548\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-2.png 794w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-2-300x207.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-2-768x530.png 768w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/p>\n<ol start=\"3\">\n<li>Once you\u2019ve accessed Power Virtual Agent portal, select \u201cCreate a chatbot\u201d and then \u201cTry the unified canvas (preview)\u201d\n<em>Note: please review the <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-virtual-agents\/preview\/limitations\">limitations of the PVA preview<\/a> for more details. The preview version is recommended if you don\u2019t intend to deploy the bot in production.<\/em><\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-3.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13543\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-3.png\" alt=\"Once you\u2019ve accessed Power Virtual Agent portal, select \u201cCreate a chatbot\u201d and then \u201cTry the unified canvas (preview)\u201d\" width=\"794\" height=\"412\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-3.png 794w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-3-300x156.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-3-768x399.png 768w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/p>\n<ol start=\"4\">\n<li>Give your bot a name (ex: MyAssist) and select the spoken language (ex: English)<\/li>\n<li>(optional) Deactivate the default custom topics if you don\u2019t intend to use them \u2013 They are named Lesson 1, 2 and 3.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-4.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13542\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-4.png\" alt=\"Deactivate the default custom topics if you don\u2019t intend to use them \u2013 They are named Lesson 1, 2 and 3.\" width=\"926\" height=\"547\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-4.png 926w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-4-300x177.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-4-768x454.png 768w\" sizes=\"(max-width: 926px) 100vw, 926px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"6\">\n<li>Under Settings &gt; Channels, select \u201cMicrosoft Teams\u201d and then click on \u201cTurn on Teams\u201d \u2013 This will enable your PVA bot to run inside Microsoft Teams.<\/li>\n<li>(optional) Once Microsoft Teams is activated, select \u201cEdit details\u201d if you can change the logo of your bot, its name, description or more. You can also select \u201cAllow your users to add this bot to a team\u201d to be able to install it into a team. Click \u201cSave\u201d if you make changes.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-5.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-13541\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-5-1024x599.png\" alt=\"Once Microsoft Teams is activated, select \u201cEdit details\u201d if you need to change the logo of your bot, its name, description or more.\" width=\"640\" height=\"374\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-5-1024x599.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-5-300x176.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-5-768x449.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-5.png 1039w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"8\">\n<li>Under Settings &gt; Authentication, select \u201cOnly in Teams\u201d and click \u201cSave\u201d. Doing so will enforce user authentication to the bot and access via Microsoft Teams only (all other channels will be deactivated)<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-6.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13540\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-6.png\" alt=\"Under Settings &gt; Authentication, select \u201cOnly in Teams\u201d and click \u201cSave\u201d.\" width=\"453\" height=\"356\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-6.png 453w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-6-300x236.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"9\">\n<li>Go to \u201cPublish\u201d, then click on \u201cPublish\u201d and confirm. Your bot is now available for you only in Microsoft Teams.<\/li>\n<li>Under \u201cChannels &gt; Microsoft Teams\u201d click on \u201cOpen bot\u201d to install the bot in Teams.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-7.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13539\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-7.png\" alt=\"Under \u201cChannels &gt; Microsoft Teams\u201d click on \u201cOpen bot\u201d to install the bot in Teams.\" width=\"450\" height=\"241\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-7.png 450w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-7-300x161.png 300w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"11\">\n<li>You\u2019ll be redirected to Microsoft Teams where you can \u201cAdd\u201d the bot as a personal app. Click on Add to install the Power Virtual Agent bot.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-8.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13538\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-8.png\" alt=\"You\u2019ll be redirected to Microsoft Teams where you can \u201cAdd\u201d the bot as a personal app. Click on Add to install the Power Virtual Agent bot.\" width=\"794\" height=\"277\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-8.png 794w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-8-300x105.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-8-768x268.png 768w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"12\">\n<li>Test your bot in Teams \u2013 Don\u2019t expect too much for now, just send a message and confirm that you receive a message \u2013 If you get an answer, congrats, your bot is now running in Teams!<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-9.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13537\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-9.png\" alt=\"Test your bot in Teams \u2013 Don\u2019t expect too much for now, just send a message and confirm that you receive a message.\" width=\"820\" height=\"555\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-9.png 820w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-9-300x203.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-9-768x520.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Step 2 \u2013 Deploy &amp; configure Azure OpenAI Service<\/h3>\n<p>Please check that you meet all the technical requirements and have an Azure subscription enabled to use the model gpt-35-turbo or gpt-4.<\/p>\n<ol>\n<li>Login to <a href=\"https:\/\/portal.azure.com\">https:\/\/portal.azure.com<\/a><\/li>\n<li>Search for Azure OpenAI and click on \u201cCreate\u201d to start a new deployment.<\/li>\n<li>Select a region that supports the models gpt-35-turbo or gpt-4 (East US and South Central US regions) and click on \u201cCreate\u201d \u2013 More details on this <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cognitive-services\/openai\/chatgpt-quickstart#prerequisites\">documentation<\/a>.<\/li>\n<li>After the deployment, go to your instance of Azure OpenAI on the Azure portal and navigate to \u201cKeys and Endpoint\u201d under \u201cResource Management\u201d \u2013 Copy \/ paste the Key value and Endpoint URL in a text file for later use.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-10.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13536\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-10.png\" alt=\"After the deployment, go to your instance of Azure OpenAI on the Azure portal and navigate to \u201cKeys and Endpoint\u201d under \u201cResource Management\u201d \" width=\"529\" height=\"315\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-10.png 529w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-10-300x179.png 300w\" sizes=\"(max-width: 529px) 100vw, 529px\" \/><\/a><\/p>\n<ol start=\"5\">\n<li>Go to Model Deployments, click on \u201cCreate\u201d and give a name to your deployment (ex: myassist-model) \u2013 Select the Model \u201cgpt-35-turbo\u201d and version 0301 or later (or gpt-4) and Save.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-11.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13535\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-11.png\" alt=\"Go to Model Deployments, click on \u201cCreate\u201d and give a name to your deployment (ex: myassist-model) \u2013 Select the Model \u201cgpt-35-turbo\u201d and version 0301 or later (or gpt-4) and Save.\" width=\"477\" height=\"660\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-11.png 477w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-11-217x300.png 217w\" sizes=\"(max-width: 477px) 100vw, 477px\" \/><\/a><\/p>\n<ol start=\"6\">\n<li>Go to Azure OpenAI Studio at <a href=\"https:\/\/oai.azure.com\/\">https:\/\/oai.azure.com\/<\/a> and select \u201cChat playground (Preview\u201d)<\/li>\n<li>From the Chat playground, select the Assistant setup \u201cShakespeare writing assistant\u201d \u2013 this will automatically fill to \u201cSystem message\u201d and provide an example of question &amp; answer. You can test the chat bot and configure different scenarios based on your requirements and what you expect from \u201cMyAssist\u201d bot. Read this <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cognitive-services\/openai\/chatgpt-quickstart#playground\">documentation<\/a> to know more about exploring the capabilities of the chat playground for ChatGPT.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-12.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-13534\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-12-1024x669.png\" alt=\"Go to Azure OpenAI Studio at https:\/\/oai.azure.com\/ and select \u201cChat playground (Preview\u201d)\" width=\"640\" height=\"418\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-12-1024x669.png 1024w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-12-300x196.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-12-768x502.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-12.png 1256w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"8\">\n<li>Once you\u2019re happy with the result of the conversation (you can come back on it later), click on \u201cClear Chat\u201d, then \u201cView code\u201d and select \u201cjson\u201d in the drop-down menu. Click on \u201cCopy\u201d and paste the JSON in a text file for later use.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-13.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13533\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-13.png\" alt=\"8. Once you\u2019re happy with the result of the conversation (you can come back on it later), click on \u201cClear Chat\u201d, then \u201cView code\u201d and select \u201cjson\u201d in the drop-down menu. \" width=\"463\" height=\"135\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-13.png 463w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-13-300x87.png 300w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-14.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13532\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-14.png\" alt=\"8. Once you\u2019re happy with the result of the conversation (you can come back on it later), click on \u201cClear Chat\u201d, then \u201cView code\u201d and select \u201cjson\u201d in the drop-down menu. \" width=\"463\" height=\"646\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-14.png 463w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-14-215x300.png 215w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Step 3 \u2013 Connect Power Virtual Agent to Azure OpenAI using Power Automate<\/h3>\n<ol>\n<li>Go to <a href=\"https:\/\/powerva.microsoft.com\">https:\/\/powerva.microsoft.com<\/a><\/li>\n<li>Under Topics, select \u201cSystem\u201d and then click on \u201cFallback\u201d \u2013 This will open the conversational flow of the Fallback topic \u2013 This topic is triggered if the bot can\u2019t determine the user\u2019s intent. This will be the default route in most cases as your bot has only basic custom topics configured.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-15.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13531\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-15.png\" alt=\"Connect Power Virtual Agent to Azure OpenAI using Power Automate with fallback topic.\" width=\"992\" height=\"765\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-15.png 992w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-15-300x231.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-15-768x592.png 768w\" sizes=\"(max-width: 992px) 100vw, 992px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"3\">\n<li>Delete all the existing steps in this flow and add a new step \u2013 Select \u201cCall an action &gt; Create a flow\u201d \u2013 This will open your Power Automate authoring canvas.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-16.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13530\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-16.png\" alt=\"Delete all the existing steps in this flow and add a new step \u2013 Select \u201cCall an action &gt; Create a flow\u201d \u2013 This will open your Power Automate authoring canvas.\" width=\"595\" height=\"448\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-16.png 595w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-16-300x226.png 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"4\">\n<li>From Power Automate, add a \u201cText\u201d input to the trigger name it \u201crequest\u201d<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-17.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13529\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-17.png\" alt=\"From Power Automate, add a \u201cText\u201d input to the trigger name it \u201crequest\u201d\" width=\"661\" height=\"369\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-17.png 661w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-17-300x167.png 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"5\">\n<li>Add an action \u201cInitialize variable\u201d of type JSON and paste the JSON saved from the Azure OpenAI chat playground in step 2. Name the variable \u201cOAI_Request\u201d like the screenshot below.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-18.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-13528\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-18-660x1024.png\" alt=\"Add an action \u201cInitialize variable\u201d of type JSON and paste the JSON saved from the Azure OpenAI chat playground in step 2. Name the variable \u201cOAI_Request\u201d like the screenshot below.\" width=\"640\" height=\"993\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-18-660x1024.png 660w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-18-194x300.png 194w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-18-768x1191.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-18.png 794w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"6\">\n<li>Update the JSON definition to include the user request from Power Virtual Agent. Pay attention to the structure and position in the JSON.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-19.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13527\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-19.png\" alt=\"6. Update the JSON definition to include the user request from Power Virtual Agent. \" width=\"661\" height=\"404\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-19.png 661w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-19-300x183.png 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Here is the JSON definition from the Shakespeare example on Azure OpenAI studio:<\/p>\n<p>&nbsp;<\/p>\n<p>{<\/p>\n<p>&#8220;messages&#8221;: [<\/p>\n<p>{<\/p>\n<p>&#8220;role&#8221;: &#8220;system&#8221;,<\/p>\n<p>&#8220;content&#8221;: &#8220;You are a Shakespearean writing assistant who speaks in a Shakespearean style. You help people come up with creative ideas and content like stories, poems, and songs that use Shakespearean style of writing style, including words like \\&#8221;thou\\&#8221; and \\&#8221;hath\u201d.\\nHere are some examples of Shakespeare&#8217;s style:\\n &#8211; Romeo, Romeo! Wherefore art thou Romeo?\\n &#8211; Love looks not with the eyes, but with the mind; and therefore, is winged Cupid painted blind.\\n &#8211; Shall I compare thee to a summer\u2019s day? Thou art more lovely and more temperate.&#8221;<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">{\r\n  \"messages\": [\r\n    {\r\n      \"role\": \"system\",\r\n      \"content\": \"You are a Shakespearean writing assistant who speaks in a Shakespearean style. You help people come up with creative ideas and content like stories, poems, and songs that use Shakespearean style of writing style, including words like \\\"thou\\\" and \\\"hath\u201d.\\nHere are some examples of Shakespeare's style:\\n - Romeo, Romeo! Wherefore art thou Romeo?\\n - Love looks not with the eyes, but with the mind; and therefore, is winged Cupid painted blind.\\n - Shall I compare thee to a summer\u2019s day? Thou art more lovely and more temperate.\"\r\n    },\r\n    {\r\n      \"role\": \"user\",\r\n      \"content\": \"Please write a short text turning down an invitation to dinner.\"\r\n    },\r\n    {\r\n      \"role\": \"assistant\",\r\n      \"content\": \"Dearest,\\nRegretfully, I must decline thy invitation.\\nPrior engagements call me hence. Apologies.\"\r\n    },\r\n    {\r\n      \"role\": \"user\",\r\n      \"content\": \"@{triggerBody()['text']}\"\r\n    }\r\n  ],\r\n  \"temperature\": 1,\r\n  \"top_p\": 0.95,\r\n  \"frequency_penalty\": 0,\r\n  \"presence_penalty\": 0,\r\n  \"max_tokens\": 400,\r\n  \"stop\": null\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<ol start=\"7\">\n<li>Add an HTTP action after the trigger to query your Azure OpenAI Service endpoint. Use the following parameters in the HTTP connector:\n<ul>\n<li>Method: POST<\/li>\n<li>URI: construct the URI following this pattern\n<strong style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">[OAI_ENDPOINT]<\/strong><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">\/openai\/deployments\/<\/span><strong style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">[OAI_DEPLOYMENT_NAME]<\/strong><span style=\"font-size: 1rem; text-align: var(--bs-body-text-align);\">\/chat\/completions?api-version=2023-03-15-preview\n<\/span>where [OAI_ENDPOINT] is the endpoint of your Azure OpenAI Service, saved from the previous configuration step 2 and [OAI_DEPLOYMENT_NAME] is the name of your OpenAI model (ex: myassist-model)\nexample: https:\/\/myassist-bot.openai.azure.com\/openai\/deployments\/MyAssist-model\/chat\/completions?api-version=2023-03-15-preview\nMode info on <a style=\"background-color: #f7f7f9; font-size: 1rem; text-align: var(--bs-body-text-align);\" href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cognitive-services\/openai\/reference#chat-completions\">Azure OpenAI Service REST API reference &#8211; Azure OpenAI | Microsoft Learn<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Headers:\n<ol>\n<li>content-type: application\/json<\/li>\n<li>api-key: [OAI_SECRET], the secret of your Azure OpenAI Service, saved from the previous configuration step 2.<\/li>\n<\/ol>\n<\/li>\n<li>Body: select the variable OAI_Request from previous action of the flow.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-20.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13526\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-20.png\" alt=\"create an Azure Key Vault to store your Azure OpenAI Service key and access it from an environment variable in Power Automate.\" width=\"794\" height=\"753\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-20.png 794w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-20-300x285.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-20-768x728.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-20-24x24.png 24w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>It is highly recommended and a best security practice to store your secret in Azure Key Vault \u2013 Please read this <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-apps\/maker\/data-platform\/environmentvariables#use-azure-key-vault-secrets-preview\">documentation<\/a> to create an Azure Key Vault to store your Azure OpenAI Service key and access it from an environment variable in Power Automate.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ol start=\"8\">\n<li>Next, we initialize the variable \u201cOAI_Response\u201d to store the text response from Azure OpenAI and the content filter.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-21.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13525\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-21.png\" alt=\"initialize the variable \u201cOAI_Response\u201d to store the text response from Azure OpenAI and the content filter.\" width=\"794\" height=\"353\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-21.png 794w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-21-300x133.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-21-768x341.png 768w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/a><\/p>\n<ol start=\"9\">\n<li>Then, we check that ChatGPT response is OK (http code 200) \u2013 If not, set an error message in OAI_Response. The test is on the \u201cStatus code\u201d of the previous HTTP action \u201cHTTP query Azure OpenAI Service\u201d and verifies that value is equal to 200.Error message value:\n<code>\u201cSorry, I couldn't generate an answer from your prompt.<\/code>\n<code>Can you rephrase your request?\u201d<\/code><\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-22.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13524\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-22.png\" alt=\"we check that ChatGPT response is OK (http code 200) \" width=\"992\" height=\"506\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-22.png 992w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-22-300x153.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-22-768x392.png 768w\" sizes=\"(max-width: 992px) 100vw, 992px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"10\">\n<li>If the condition is true (If YES path = http response code is 200), we configure the following actions:\n<ol>\n<li>Parse the JSON of the HTTP response body based on the schema below.<\/li>\n<li>Set the value of OAI_Response with the text response from the Azure OpenAI Service. Use the following expression:\n<code>body('Parse_JSON')['choices'][0]['message']['content']<\/code>Note: only the first answer generated by Azure OpenAI is extracted. Multiple responses are not supported in this pattern.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-23.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13523\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-23.png\" alt=\"If the condition is true (If YES path = http response code is 200), we configure the following actions:\" width=\"595\" height=\"652\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-23.png 595w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-23-274x300.png 274w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Schema definition for the Parse JSON action:<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">{\r\n    \"type\": \"object\",\r\n    \"properties\": {\r\n        \"choices\": {\r\n            \"type\": \"array\",\r\n            \"items\": {\r\n                \"type\": \"object\",\r\n                \"properties\": {\r\n                    \"finish_reason\": {},\r\n                    \"message\": {\r\n                        \"type\": \"object\",\r\n                        \"properties\": {\r\n                            \"content\": {\r\n                                \"type\": \"string\"\r\n                            }\r\n                        }\r\n                    }\r\n                },\r\n                \"required\": [\r\n                    \"finish_reason\",\r\n                    \"message\"\r\n                ]\r\n            }\r\n        }\r\n    }\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<ol start=\"11\">\n<li>Configure Power Automate flow to send the response back to Power Virtual Agent. Add an output to the existing action and set the value to the variable \u201cOAI_Response\u201d.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-24.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13522\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-24.png\" alt=\"Configure Power Automate flow to send the response back to Power Virtual Agent.\" width=\"926\" height=\"360\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-24.png 926w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-24-300x117.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-24-768x299.png 768w\" sizes=\"(max-width: 926px) 100vw, 926px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"12\">\n<li>Rename the flow as \u201cAzure OpenAI call flow\u201d and Save \u2013 Your Power Automate flow (wrapped) should look like this.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-25.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13521\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-25.png\" alt=\"12. Rename the flow as \u201cAzure OpenAI call flow\u201d and Save.\" width=\"453\" height=\"388\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-25.png 453w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-25-300x257.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/a><\/p>\n<ol start=\"13\">\n<li>Back in Power Virtual Agent, map your Power Virtual Agent variables to Power Automate input \/ output.<\/li>\n<\/ol>\n<ul>\n<li>Power Automate input \u201crequest\u201d = PVA system variable \u201cActivity.Text\u201d<\/li>\n<li>Power Automate output \u201cresponse\u201d = PVA topic variable \u201cresponse\u201d (create a new one)<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-26.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13520\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-26.png\" alt=\"Back in Power Automate, map your Power Virtual Agent variables to Power Automate input \/ output.\" width=\"463\" height=\"542\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-26.png 463w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-26-256x300.png 256w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>The result should look like this:<\/p>\n<ol start=\"14\">\n<li>Add a last action to send the response to Microsoft Teams using an Adaptive Card format. Select \u201c+\u201d and \u201cSend a message\u201d \u2013 Then \u201cAdd\u201d &gt; \u201cAdaptive Card \u2013 In the editor, select \u201cEdit formula\u201d and paste the JSON definition below. Click on Save to validate the changes.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-27.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13519\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-27.png\" alt=\"Add a last action to send the response to Microsoft Teams using an Adaptive Card format.\" width=\"567\" height=\"644\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-27.png 567w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-27-264x300.png 264w\" sizes=\"(max-width: 567px) 100vw, 567px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>JSON to be added in the \u201cEdit formula\u201d section of Power Virtual Agent in the Adaptive Card editor.<\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">{\r\n    'type': \"AdaptiveCard\",\r\n    '$schema': \"http:\/\/adaptivecards.io\/schemas\/adaptive-card.json\",\r\n    'version': \"1.3\",\r\n    'body': [\r\n        {\r\n            'type': \"TextBlock\",\r\n            'text': \"Answer generated by Azure OpenAI using ChatGPT model \",\r\n            'wrap': true,\r\n            'size': \"Medium\",\r\n            'weight': \"Bolder\"\r\n        },\r\n        {\r\n            'type': \"Container\",\r\n            'items': [\r\n                {\r\n                    'type': \"TextBlock\",\r\n                    'text': Text(Topic.response),\r\n                    'wrap': true\r\n                }\r\n            ],\r\n            'style': \"emphasis\"\r\n        },\r\n        {\r\n            'type': \"TextBlock\",\r\n            'text': \"NOTE: This service is in preview version and model does not have context of previous messages.\",\r\n            'wrap': true,\r\n            'color': \"Accent\",\r\n            'size': \"Small\"\r\n        }\r\n    ]\r\n}<\/code><\/pre>\n<ol start=\"15\">\n<li>Publish the new version of the bot.<\/li>\n<\/ol>\n<h3>Step 4 \u2013 Test and deploy to users<\/h3>\n<p>At this stage, you can test your bot in Power Virtual Agent and get its responses in an Adaptive card format. Once you\u2019re happy with the tests, from Power Virtual Agent:<\/p>\n<ul>\n<li>Go to Settings &gt; Channels &gt; Microsoft Teams<\/li>\n<li>Click on \u201cAvailability options\u201d<\/li>\n<li>Select \u201cShow to my teammates and shared users\u201d (or show to everyone in my org)<\/li>\n<li>Enter individual names, emails or security groups.<\/li>\n<li>Click on Share to make this app visible in \u201cBuilt by your colleagues\u201d in Teams app store.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-28.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13518\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-28.png\" alt=\"test your bot in Power Virtual Agent and get its responses in an Adaptive card format.\" width=\"604\" height=\"612\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-28.png 604w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-28-296x300.png 296w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-28-24x24.png 24w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-28-48x48.png 48w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-28-96x96.png 96w\" sizes=\"(max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Your bot MyAssist running in Power Virtual Agent<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-29.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13517\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-29.png\" alt=\"Your bot MyAssist running in Power Virtual Agent\" width=\"463\" height=\"837\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-29.png 463w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-29-166x300.png 166w\" sizes=\"(max-width: 463px) 100vw, 463px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Your bot MyAssist running in Microsoft Teams<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-13516\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30.png\" alt=\"Your bot MyAssist running in Microsoft Teams.\" width=\"992\" height=\"977\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30.png 992w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30-300x295.png 300w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30-768x756.png 768w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30-24x24.png 24w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30-48x48.png 48w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2023\/04\/ChatGPT-blog_image-30-96x96.png 96w\" sizes=\"(max-width: 992px) 100vw, 992px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>What\u2019s next?<\/h2>\n<p>Now that you have your ChatGPT bot running in Teams, you can learn directly from users\u2019 requests and better understand the questions, use-cases, and problems they are trying to solve with this new technology. All of that while keeping all these experiments in a safe and secure environment.<\/p>\n<p>Microsoft Teams with Power Virtual Agent bring together an audit and analytics layer. With Azure OpenAI, you get all the flexibility of the technology combined with the playground to perfect the solution to the scenarios that are relevant at your company.<\/p>\n<p>AI and Copilot are infused in all our services, providing full flexibility on your design and for everyone.<\/p>\n<p>I hope you find this article interesting. Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article describes different options to implement the ChatGPT (gpt-35-turbo) model of Azure OpenAI in Microsoft Teams.<\/p>\n","protected":false},"author":116409,"featured_media":13566,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[128,20],"tags":[231,230,167],"class_list":["post-13514","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-teams","category-power-platform","tag-azure-openai","tag-chatgpt","tag-power-virtual-agent"],"acf":[],"blog_post_summary":"<p>This article describes different options to implement the ChatGPT (gpt-35-turbo) model of Azure OpenAI in Microsoft Teams.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/13514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/116409"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=13514"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/13514\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/13566"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=13514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=13514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=13514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}