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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Sending an HTTP reques...
Copilot Studio
Unanswered

Sending an HTTP request to OPEN AI API in Copilot Studio Virtual Agents

(0) ShareShare
ReportReport
Posted on by 10

Is there an example of how to setup this http call properly? The documentation I find is not relative to the newer versions of PVA. Also, Automate "complete text..." does not work as it points to 3.5.

 

I'm sending a string to Chatgpt 4.0 that I have and expect a return answer. It passes authentication then fails. See comps.

I have the same question (0)
  • Freddie_B Profile Picture
    60 on at

    Does anyone can help me with this? Or has any idea why this is hapenning? I have a similiar problem

     

    Your help will be much appreciated 😊

     

    I'm attempting to send an HTTP request to OpenAI's service. It seems to function correctly overall. However, when I dynamically assign the content of the user field in the JSON payload to a variable where the question is stored, the response indicates that the information isn't found in the retrieved data. Strangely, if I manually input the same question into the content field, I receive the correct response.

    @HenryJammes , would you happen to have any clue why this is hapenning?

     

    Thanks everyone

     

    This is the code:

     

     

     

     

     

     

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnUnknownIntent
     id: main
     priority: -1
     actions:
     - kind: SetVariable
     id: setVariable_J8onVi
     variable: Topic.UserQuestion
     value: =System.Activity.Text
    
     - kind: HttpRequestAction
     id: vdrcdy
     method: Post
     url: https://ai-XXXXXXXXXXXXXXXXX.openai.azure.com/openai/deployments/gpt-35-turbo-16k/extensions/chat/completions?api-version=2023-06-01-preview
     headers:
     api-key: XXXXX-XXX-XXXXX-XXXXX-XXXX
    
     body:
     kind: JsonRequestContent
     content:
     kind: ValueExpression
     literalValue:
     dataSources:
     - parameters:
     endpoint: https://xxxx-xx-xxx-xx.search.windows.net
     fieldsMapping:
     contentFields:
     - Value: content
    
     contentFieldsSeparator: |
     
     filepathField: metadata_spo_item_name
     titleField: Name
     urlField:
     vectorFields:
    
     filter:
     indexName: sharepoint-index
     inScope: true
     key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     queryType: simple
     roleInformation: You are an AI assistant and you are part of our organization. You need to be polite when you give the answers. The information you will be giving is from an internal SharePoint.
     semanticConfiguration: default
     strictness: 3
     topNDocuments: 5
    
     type: AzureCognitiveSearch
    
     deployment: gpt-35-turbo-16k
     max_tokens: 800
     messages:
     - content: You are an AI assistant and you are part of our organization. You need to be polite when you give the answers. The information you will be giving is from an internal SharePoint.
     role: system
    
     - content: ${Topic.UserQuestion}
     role: user
    
     stop:
     stream: false
     temperature: 0
     top_p: 1
    
     response: Topic.Response
     responseSchema:
     kind: Record
     properties:
     choices:
     type:
     kind: Table
     properties:
     index: Number
     messages:
     type:
     kind: Table
     properties:
     content: String
     end_turn: Boolean
     index: Number
     role: String
    
     created: Number
     id: String
     model: String
     object: String
     usage:
     type:
     kind: Record
     properties:
     completion_tokens: Number
     prompt_tokens: Number
     total_tokens: Number
    
     - kind: SendActivity
     id: sendActivity_CUSi4i
     activity: "{Last(Last(Topic.Response.choices).messages).content}"
    
     - kind: EndDialog
     id: a1Vse4

     

     

     

     

     

     

     

     



           
  • adilei Profile Picture
    on at

    Can use assign the payload to a variable before invoking an HTTP request and validate it was populated correctly?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 251 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 201 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 93 Moderator

Last 30 days Overall leaderboard