web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Integrate a PVA chatbo...
Copilot Studio
Unanswered

Integrate a PVA chatbot with Azure OpenAI using your data - TBD

(0) ShareShare
ReportReport
Posted on by 90

First, I use the method from @HenryJammes ,It's good for my prod env to use PVA ChatBot to answer Employee questions,But sometime someone input key words it not good, and will get not good answer from my bot.

Two weeks ago,I read Azure OpenAI on your data (preview)This way support semantic search.

Maybe, It's a better way for use PVA chatBot answer your Employee questions.

Here is my Step to use Azure OpenAI on your data (preview) in my PVA:

1. I follow Quickstart: Chat with Azure OpenAI models using your own data complete the setting and upload my data.

2. I Create an Topic named "Cognitive search"

Screenshot 2023-07-07 at 9.02.41 AM.png

3. I create Power automate flow in step 2's action

Screenshot 2023-07-07 at 9.07.37 AM.png

4.I trigger the flow and got output from Azure Cognitive search

 

 

{
 "id": "12345678-1a2b-3c4e5f-a123-12345678abcd",
 "model": "",
 "created": 1684304924,
 "object": "chat.completion",
 "choices": [
 {
 "index": 0,
 "messages": [
 {
 "role": "tool",
 "content": "{\"citations\": [{\"content\": \"\\nCognitive Services are cloud-based artificial intelligence (AI) services...\", \"id\": null, \"title\": \"What is Cognitive Services\", \"filepath\": null, \"url\": null, \"metadata\": {\"chunking\": \"orignal document size=250. Scores=0.4314117431640625 and 1.72564697265625.Org Highlight count=4.\"}, \"chunk_id\": \"0\"}], \"intent\": \"[\\\"Learn about Azure Cognitive Services.\\\"]\"}",
 "end_turn": false
 },
 {
 "role": "assistant",
 "content": " \nAzure Cognitive Services are cloud-based artificial intelligence (AI) services that help developers build cognitive intelligence into applications without having direct AI or data science skills or knowledge. [doc1]. Azure Machine Learning is a cloud service for accelerating and managing the machine learning project lifecycle. [doc1].",
 "end_turn": true
 }
 ]
 }
 ]
}

 

 

not complete yet, and will update. 

Categories:
I have the same question (0)
  • HenryJammes Profile Picture
    Microsoft Employee on at

    Hi @angerfire1213 awesome to see you're working on this!

    FYI @remidyon managed to get a custom integration working 👀

  • remidyon Profile Picture
    Microsoft Employee on at

    Hey @angerfire1213 , like @HenryJammes mentioned I was able to connect my PVA directly to Azure OpenAI Studio. Same as you for the first step, create the blob storage, indexes with azure cog. service, activate semantic search, etc. up to the point where it works in Azure OpenAI Studio Playground (here I uploaded a bunch of fake healthcare plans PDF in cog. service):

     

    remidyon_0-1689188077979.png

     

    Then I created a Power Automate flow to call the Azure OpenAI Studio API directly and this is where it gets tricky: you need 3 URLs and 2 API Key to make this work!

     

    The documentation for this is a little bit spread everywhere, I had to read all the following docs to make it work:

    Using your data with Azure OpenAI Service - Azure OpenAI | Microsoft Learn

    Azure OpenAI Service REST API reference - Azure OpenAI | Microsoft Learn

    Create a Cognitive Services resource in the Azure portal - Azure Cognitive Services | Microsoft Learn

    Azure OpenAI Service embeddings tutorial - Azure OpenAI | Microsoft Learn

    How to work with the ChatGPT and GPT-4 models - Azure OpenAI Service | Microsoft Learn

     

    I will save you some time and give you my HTTP request detail:

    remidyon_1-1689188432480.png

    Notes:

    - the API version in the URI is important, otherwise the API call will fail. Same for the chatgpt_url. 

    - the "extensions" part in the main URI is also required (but not in the chatgpt_url!!), this was also something that caused me troubles

    - the 2 keys in the header are the same, but you need a different one in the body of the call (yes - this is tricky)

     

    And here is the body:

     

    {
     "dataSources": [
     {
     "type": "AzureCognitiveSearch",
     "parameters": {
     "endpoint": "YOUR_AZURE_COG_SEARCH_URL",
     "key": "YOUR_AZURE_COG_SEARCH_KEY",
     "indexName": "YOUR_AZURE_COG_SEARCH_INDEX"
     }
     }
     ],
     "messages": [
     {
     "role": "user",
     "content": @{triggerBody()['text']}
     }
     ],
     "temperature": 0,
     "top_p": 1,
     "frequency_penalty": 0,
     "presence_penalty": 0,
     "max_tokens": 800,
     "stop": null
    }

     

     

    After that I am able to parse the JSON in Power Automate, extract the result and pass that back to PVA (I am unable to make the link to the source work though - maybe that is something I can improve in the future)

    remidyon_2-1689188670595.png

     

    Here is the result of "Azure OpenAI on your data" in PVA:

    remidyon_3-1689188709822.png

     

  • angerfire1213 Profile Picture
    90 on at

    Hey @remidyon,Thank you for great share! It's work fine in my env! 

    Screenshot 2023-07-13 at 1.19.36 PM.png

    And hope link to the source!

    I use select and expression try to do this but looks not good :

    From:

    take(split(outputs('Compose'),'metadata'),add(length(split(outputs('Compose'),'metadata')),-1))

    Link:

    take(concat('https',last(split(item(),'https'))),add(length(concat('https',last(split(item(),'https')))),-4))

    Screenshot 2023-07-13 at 1.21.54 PM.png

  • angerfire1213 Profile Picture
    90 on at

    Hi @remidyon cloud you please share your  "parse JSON","init Var","Apply to each" in the PA Follow?remidyon_2-1689188670595.png

  • remidyon Profile Picture
    Microsoft Employee on at

    Hi @angerfire1213 

     

    Here are the detailed steps:

     

    ParseJSON is to extract the data from HTTP call.

     

    Screenshot 2023-08-09 083701.png

     

    Here is the Schema I used:

    {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "model": {
     "type": "string"
     },
     "created": {
     "type": "integer"
     },
     "object": {
     "type": "string"
     },
     "choices": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "index": {
     "type": "integer"
     },
     "messages": {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "index": {
     "type": "integer"
     },
     "role": {
     "type": "string"
     },
     "content": {
     "type": "string"
     },
     "end_turn": {
     "type": "boolean"
     }
     },
     "required": [
     "index",
     "role",
     "content",
     "end_turn"
     ]
     }
     }
     },
     "required": [
     "index",
     "messages"
     ]
     }
     }
     }
    }

     

    And here is the detail for the loop:

    Screenshot 2023-08-09 083723.png

     

    But no need to bother with all this anymore: Microsoft just released the ability to deploy Azure OpenAI Studio "chat with your data" directly into PVA! 

    Create Generative AI solutions with Power Virtual Agents and Azure OpenAI Services | Microsoft Power Virtual Agents

     

    Screenshot 2023-08-09 084150.png

     

  • angerfire1213 Profile Picture
    90 on at

    Wow! Big thank you @remidyon !   love it and can not wait to try it! https://powervirtualagents.microsoft.com/en-us/blog/create-generative-ai-solutions-with-power-virtual-agents-and-azure-openai-services/ 

  • angerfire1213 Profile Picture
    90 on at
  • HenryJammes Profile Picture
    Microsoft Employee on at

    As @remidyon said, Create Generative AI solutions with Power Virtual Agents and Azure OpenAI Services | Microsoft Power Virtual Agents is now the way to go 🙂

     

    @angerfire1213 the native integration between Azure OpenAI on your data and PVA only supports the new unified authoring version. In general, no new features should be expected on the classic version of PVA.

    For classic bots, you need to adopt a custom approach to integrate Azure OpenAI, through Power Automate cloud flows or HTTP requests in Bot Framework Composer dialogs.

  • AbigailCuadra Profile Picture
    15 on at

    Hi @HenryJammes , I have connected Azure Open AI with my own data stored in Azure Blob Storage to Power Virtual agent and it works, however, the reference URL added to each responses is getting my blob storage path of each document which is not accessible properly by the users. How can we replicate the behaviour of Azure Open AI Chat playground where citations are getting shown properly to the users? 

  • HenryJammes Profile Picture
    Microsoft Employee on at

    Hi @AbigailCuadra 

     

    There is work in progress to support citation management, but this will of course depend on the channel and where you deploy your PVA bot.

     

    Henry

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 315

#2
11manish Profile Picture

11manish 183

#3
Haque Profile Picture

Haque 108

Last 30 days Overall leaderboard