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 / Generative Answers Var...
Copilot Studio
Suggested Answer

Generative Answers Variable issues inside copilot studio

(0) ShareShare
ReportReport
Posted on by
I’m trying to extract two values example name and city (from userinput message) from a Generative Response JSON using ParseJSON(), but Copilot Studio keeps throwing ‘JSON could not be parsed’ even though the formula validates. Has anyone solved this issue where the runtime value includes hidden extra characters and breaks JSON parsing?

which is in key value par 
{"name": "Microsoft", "City": "NYC"}



so extracting it using Text(ParseJson(topic.agentextractedvalue).Name)

can someone help me on this?
 
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,362 Super User 2025 Season 2 on at
     
    Can you share the actual input from the user, what it looks like from the Activities tab.
     
    Does it ever work? Are you getting this in the designer or at real published run time?
  • VY-13120534-0 Profile Picture
    on at
    this is the error message i am getting. 
     
    I wrote this prompt
    You are an AI assistant that extracts structured data from user input.
     
    UserText:
     
    Activity.Text
    string
     
    Extract the following values if present:
    • ProjectArea
    • RequestType
    Return the result in JSON format like this:
     

    {Topic.ProjectArea}: " ",
    {Topic.RequestType}: " "
     
    If a value is missing, leave it as an empty string.
    inside prompt session of generative answers
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,362 Super User 2025 Season 2 on at
     
    This is not valid JSON and it depends on if you want it to be two properties of a single or separate things
     
    {Topic.ProjectArea}: " ",
    {Topic.RequestType}: " "
    This is valid JSON
    {
      "Topic.ProjectArea": "",
      "Topic.RequestType": ""
    }
     
    or even 
     
    [
      {
        "Topic.ProjectArea": "",
        "Topic.RequestType": ""
      }
    ]
     
    But what you pasted is not.
     
    Also have you thought about making them Entities so they are easily extracted?
     
    OH And it looks like you are placing Topic.XXX where the JSON name should be, but that would make it Dynaimc, which ... I don't know of that is ok or not because its going to actually put a value.
     
    What I mean is
     
    If Topic.ProjectArea is = "Boo" then you are going to have Boo = "", is that what you really want, or do you want the actual value that was returned to be set equal to a Name called "Topic.ProjectArea", or are you trying to set a variable value? which again would look like Boo = "something" and not sure how that makes sense.

    If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.

    Thank you!
    Sincerely, Michael Gernaey
  • Suggested answer
    S-Venkadesh Profile Picture
    927 Moderator on at
     

    You can achieve a consistent JSON response by defining a clear instruction (system prompt) for the AI model.
     
     
    Option 1: Simple instruction

    You can use the following instruction, which ensures the response is always returned in JSON format:
    You are an AI assistant that extracts structured information from user input.
    
    ## Instructions
    - Analyze the input text.
    - Extract the following fields **only if they are explicitly present**:
      - ProjectArea
      - RequestType
    - Do not infer or fabricate values.
    - If a value is not present, return it as null.
    
    ## Output
    - Return the result **strictly in JSON format** using the structure below.
    
    ### Sample Output
    ```json
    {
      "ProjectArea": "Finance",
      "RequestType": "Access Request"
    }
    
     
     
    Option 2: Most reliable approach – orchestrated prompt
    For better reliability, especially in Copilot or multi-turn scenarios, orchestrate the topic with a prompt that explicitly enforces JSON output:
     
    You are an AI assistant designed to extract structured information from user input text.
    
    Instructions:
    1. Analyze the provided input text carefully.
    2. Extract the following fields only if they are explicitly present in the text:
       - ProjectArea
       - RequestType
    3. Do not infer, guess, or fabricate any values. If a field is not explicitly mentioned, assign it a value of null.
    4. Return the extracted information strictly in valid JSON format following the structure below:
    
    {
      "ProjectArea": "Finance",
      "RequestType": "Access Request"
    }
    
    Guidelines:
    - Only extract the fields if they appear explicitly.
    - Maintain valid JSON format with no additional text.
    - Use null for any missing fields.
    
    Input text: <input>
     
    Refer to the sample screenshot for implementation details.
     
     
     
     I hope this information helps! If it does, please consider giving a 👍.
    If this solved your issue, please mark it as  Verified Answer
    Best regards,
    S-Venkadesh
     

     

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 250 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

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

#3
S-Venkadesh Profile Picture

S-Venkadesh 103 Moderator

Last 30 days Overall leaderboard