Hi, I am trying the parse particular data from a email , IP Address, host , profile, checked columns, The data is extracted from email as json format, but i fail parse and extract the particular data from table embedded in the email. Pls suggest. Attached few of the doc i used in email and json file.Any help will be appreciated
Json.zip (22.8 KB)
.
@raju.saini You can do it in multiple ways.
- You can use âextract textâ activity to extract values from email content.
- You can use Regx to extract values
- The easiest way is to usse ASK AI activity for the same.
Example:
Step 1: create a variable and store email body content test= email_content[0].text
Step 2: Use Ask AI and mention below prompt to chatGpt
'Given the following request â
- test + â, analyze the text and format the answer in the following JSON format: {âExtract IP addressâ: âvalueâ, âhostâ: âvalueâ, âprofileâ: âvalueâ, âcheckedâ: âvalueâ}â
Step 3: store result in JSON and parse the JSON
result_json = JSON.parse(askai[âchoicesâ][0][âtextâ])
Now you can fetch ipaddress,Host,Profile and Checked easily as they are in JSON format
Thanks for the solution. Seems Good. Although one concern although i parsing multiple rows for the table or different text , askAI seems to return the same result. Any suggestion.
Result Json
{âidâ:âcmpl-7J4VayXoVYpKWseEPBvgse5pymnISâ,âobjectâ:âtext_completionâ,âcreatedâ:â2023-05-22T18:25:18.000Zâ,âmodelâ:âtext-davinci-003â,âchoicesâ:[{âtextâ:â\n\n{âExtract IP addressâ: â192.168.1.1â, âHost Nameâ: âmyhostnameâ, âProfileâ: âdefaultâ, âCheckedâ: âtrueâ}â,âindexâ:0,âlogprobsâ:null,âfinish_reasonâ:âstopâ}],âusageâ:{âprompt_tokensâ:73,âcompletion_tokensâ:64,âtotal_tokensâ:137}}
@raju.saini You mean, you are getting same result for different data? I assume something missing in logic. you can send .neek file here with different data you are trying to parse. we can take a look
Hi , PFA the json for email extract & neek.
AskAI.zip (3.2 KB)
modified.zip (3.5 KB)
I have modified the flow. You can now see all the table result.
Root cause: Variable was using inside âSet a valueâ, which is why you were getting same result everytime. Always use âCalculate a valueâ when using dynamic values(varuables)
Please use correct Javascript line to parse the data from JSON
1 Like