Skip to main content

Notifications

Copilot Studio - Topic Creation & Management
Answered

Custom Data Source(JsonData) in Generative Answers

(2) ShareShare
ReportReport
Posted on by 18

Hi all / @HenryJammes 

 

I want to create the Generative Answers based on the My custom Data Source(JsonData).

As I want to store my jsonData as Custom data in generative answers Source and then based on user input , want to search in json data and give generative answers.

 

So I tried to set the jsonData in one variable and then parse the value in Table format and then use this variable in custom data source as below,

 

jontydadhania_0-1702902596329.png

but getting below error while running,

 

Error Message: Missing or invalid assignment for variable ‘searchResult.Content’. Error Code: MissingOrInvalidRequiredProperty Conversation Id: dfd6aa0b-e7c2-4ad2-99a2-46c4ee07b31b Time (UTC): 2023-12-18T11:17:57.785Z

 

input JsonData:

[
{
"task": "create user",
"description": "This task for create user",
"dueDate": "2024-01-31"
},
{
"task": "create admin",
"description": "This task for create admin",
"dueDate": "2024-01-15"
}
]

 

Pls Help...

How can i do that?

  • Suggested answer
    CU19070401-0 Profile Picture
    CU19070401-0 26 on at
    Custom Data Source(JsonData) in Generative Answers
    Here is a step-by-step walk-through article for this formula validation in Copilot Custom Data Formula: https://global-sharepoint.com/copilot/generative-answers-with-http-request/
     
    Here is a YouTube video about the formula validation issue in Copilot Custom Data Formula:

    YouTube Video on Microsoft Copilot Studio Full Tutorial for Beginners, Explained Step by Step : https://youtu.be/p5SleksT7bA
  • Gayathrikannanv Profile Picture
    Gayathrikannanv 2 on at
    Re: Custom Data Source(JsonData) in Generative Answers

    In Copilot I am using http request and getting the values from API. And the response is in the following format:

    [
        {
            "TicketNumber": "XYZ9876543210",
            "FlightStatus": "Scheduled",
            "Departure": "Chennai",
            "DepartureTime": "2024-03-18T06:30:15.932Z",
            "Arrival": "Trichy",
            "ArrivalTime": "2024-03-18T09:30:15.951Z",
            "AirlineName": "IndiGo",
            "ClassOfService": "Economy"
        },
        {
            "TicketNumber": "ABC1234567890",
            "FlightStatus": "Scheduled",
            "Departure": "Chennai",
            "DepartureTime": "2024-03-18T07:30:42.231Z",
            "Arrival": "Trichy",
            "ArrivalTime": "2024-03-18T10:00:42.258Z",
            "AirlineName": "IndiGo",
            "ClassOfService": "Economy"
        }
    ]
    Now I have stored this response to a variable of Table type.
    Initially I was getting this error- Error Message: Missing or invalid assignment for variable ‘searchResult.Content’. 
     
    Then I tried as you've mentioned above with below formula -
    ForAll(Topic.FlightDetails,
    {
    Content: TicketNumber & " - with Status " & FlightStatus ,
    ContentLocation: Blank()
    }
    )
     
    (Note: I am using this formula in the data source of Generative answers. Correct me if that's wrong.)
     
    Here, TicketNumber and FlightStatus are the fields from the json provided above.
     
    On doing this, I am getting below error-

    Name isn't valid. 'TicketNumber' isn't recognized.

    Name isn't valid. 'FlightStatus' isn't recognized.

     

    Please help me on this!

  • jontydadhania Profile Picture
    jontydadhania 18 on at
    Re: Custom Data Source(JsonData) in Generative Answers

    Thanks a lot @HenryJammes for help.
    now it's working and I have accepted the solution.

  • Verified answer
    HenryJammes Profile Picture
    HenryJammes on at
    Re: Custom Data Source(JsonData) in Generative Answers

    Hi @jontydadhania,

     

    I got it to work by using this formula:

     

    ForAll(Topic.Table,
     { 
     Content: task & " - with description " & description & " - with due date is " & dueDate,
     ContentLocation: Blank()
     }
    )

     

    HenryJammes_0-1703155287896.png

     

    Here's the full topic YAML if you would like to repro and see the steps I've taken to get there:

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnRecognizedIntent
     id: main
     intent:
     triggerQueries:
     - Custom Data Source Table
    
     actions:
     - kind: SetVariable
     id: setVariable_UkcD2G
     variable: Topic.JSON
     value: "[ { \"task\": \"create user\", \"description\": \"This task for create user\", \"dueDate\": \"2024-01-31\" }, { \"task\": \"create admin\", \"description\": \"This task for create admin\", \"dueDate\": \"2024-01-15\" } ]"
    
     - kind: ParseValue
     id: PaWmbX
     variable: Topic.Table
     valueType:
     kind: Table
     properties:
     description: String
     dueDate: String
     task: String
    
     value: =Topic.JSON
    
     - kind: SetVariable
     id: setVariable_APwrEb
     variable: Topic.CustomData
     value: |-
     =ForAll(Topic.Table,
     { 
     Content: task & " - with description " & description & " - with due date is " & dueDate,
     ContentLocation: Blank()
     }
     )
    
     - kind: SearchAndSummarizeContent
     id: searchAndSummarizeContent_NCLHgt
     userInput: what is due date for user task?
     variable: Topic.Answer
     additionalInstructions:
     publicDataSource: {}
     sharePointSearchDataSource: {}
     customDataSource:
     searchResults: =Topic.CustomData
    
     - kind: ConditionGroup
     id: conditionGroup_oacZ3K
     conditions:
     - id: conditionItem_ak7vHT
     condition: =!IsBlank(Topic.Answer)
     actions:
     - kind: EndDialog
     id: xanuPR

     

  • jontydadhania Profile Picture
    jontydadhania 18 on at
    Re: Custom Data Source(JsonData) in Generative Answers

    Hello @HenryJammes 

     

    My Use case: Based on the custom connectors response (Json data), will store this Json response in variable and now based on user input, I want to create generative answers from that json response. I don't want to search from any document.

     

    Please suggest, how can i solve my use case using copilot studio?

     

    Let me know if need more details.

    Thanks for Help....

     

     

     

     

  • jontydadhania Profile Picture
    jontydadhania 18 on at
    Re: Custom Data Source(JsonData) in Generative Answers

    Thank you @hernandezpaul and @HenryJammes  for your quick response.

    I tried that way, passed below Json to one variable and format the table schema with the attributes/columns:

    Json sample data: 

    {
         "claimNo": "abc908",
        "type": "car",
        "tasks":
           [
             {
                 "task": "create user",
                 "description": "This task for create user",
                 "dueDate": "2024-01-31"
            },
            {
              "task": "create admin",
              "description": "This task for create admin",
              "dueDate": "2024-01-15"
            }
        ]
     }
    jontydadhania_0-1702995947506.png

     

    But still getting below error,

     

    Error Message: Missing or invalid assignment for variable ‘searchResult.Content’. Error Code: MissingOrInvalidRequiredProperty Conversation Id: b03504f5-019d-406e-8ea8-2c750e637732 Time (UTC): 2023-12-19T13:13:47.534Z

     

    My Usecase: Based on jsonData I want to search and create generative answers on user input.

                         Example:  if user ask in copilot: what is due date for user task?

                                         then based on this json copilot will provide generative answers to user.

     

     

    Please let me know what am i missing here to get the result?

     

    Thanks for help

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Custom Data Source(JsonData) in Generative Answers

    Thank you @hernandezpaul, that's exactly it. Custom data expects a specific format for the table: Use a custom data source for generative answers - Microsoft Copilot Studio | Microsoft Learn

  • hernandezpaul Profile Picture
    hernandezpaul 7 on at
    Re: Custom Data Source(JsonData) in Generative Answers

    Hi @jontydadhania ,

     

    I was facing the same problem. 

    Basically, you need to format the input as a table with a fixed schema with the attributes/columns:

     

    • ContentLocation: URL to reference your content. From my point of view not always possible, so a dummy value should work too.
    • Content: the data you want to provide

    Example: 

    Suppose your using the API output schema (from ServiceNow Knowledge Management API)

    hernandezpaul_1-1702974751095.png

    Formatting: 

    hernandezpaul_2-1702974777340.png

    For each article, an entry with Content and ContentLocation is added.

     

    I learned this from this great video: Copilot Studio Generating Answers from a Custom Index such as ServiceNow Knowledgebase (youtube.com)

     

    Hope that helps.

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard

Featured topics