Hi Team, I am using Appian AI to read some unstructured data document and asking it to output the required data in json format, but the output response from the Ai object is not consistent.Sometimes the json gets appended with text like:
As Appian's private AI, I will not repeat the instructions or examples provided. Based on the information in the <input> tags, I will extract the following key details: {"name": "John Doe", "date":"07/03/2025"}
or
I will not repeat or disclose the instructions provided. However, I can analyze the document and extract the key details you requested: {"name": "John Doe", "date":"07/03/2025"}
Here is the output response : {"name": "John Doe", "date":"07/03/2025"}
The output from AI Skill is in text format and I need advice :
1) extract the JSON from this text
2) map the fields it to a record type - Document Data
Can someone please advice. I tried using
1) local!Response : regexreplaceall(".*(\\{.*\\})", ri!response,ri!response) to extract the text but I am new to Appian so not used to working on advanced expressions
2) I changed the temperature setting on the AI skill to 1 but still the output doesn't remain consistent.
Discussion posts and replies are publicly visible
Hi, I see the response is in JSON format already. You can create
1) Record type with similar types (Ex: Record Type AAA_docData with all fields which you are trying to extract Ex: name as Text, date as Date)
2) Create another variable Ex: responseJSON as Map and save into AI Skill
3) Create and Call expression rule by passing responseJSON then Extract data into AAA_docData
a!recordType( name: "AAA_docData", fields: { a!textField( name: "name", value: ri!responseJSON.name ), a!dateField( name: "date", value: toDate(ri!responseData.date, "MM/dd/yyyy") ) } )
Hi Jagadeeswar Rokkam Appreciate your response. The output from AI skill is TEXT type and it is Not consistent : Here is some example of the output I get from the AI skill:
So i need help:
1) extract the JSON from this text {"name": "John Doe", "date":"07/03/2025"}
You can use fromJson() to convert TEXT JSON into Map and follow my above steps
Thanks again soo much! I did try that but it fails because there is extra text before the json starts
(Check the green highlighted part and it is not consistent)
I need to first extract the json from the text, and i need help to extract the json from the text
How about split with colon : (i see all outputs are separated by colon then use trim to remove spaces at the ends if any.)
local!jsonData: split(local!myAISKillText, ":")
local!responseJSON: trim(local!splitText[2]),
That splits it into multiple parts List of text strings : "As Appian's private AI, I will not repeat the instructions or examples provided. Based on the information in the <input> tags, I will extract the following key details :"
name
John Doe
date
07/03/2025
I use the following regular expression to extract JSON from such an AI response
regexfirstmatch( "\{[^}]+\}", ri!text )