Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

On Email Intent Indentification agent -Agent Output is not available in the flow

pariknarain
Mega Contributor

Building a flow to analyse the inbound email for intent and then decide the next steps to create incident or any other record (action).

1) Based on the docs, new email intents were created.

2) Activated the Intent Identification Agent

3) Tested the Intent Identification Agent on a few emails and the final output ( manual agent test) shows correct output as 'Output : **MATCHED INTENTS** : { "intent": "<description_start>The user is not reporting an issue which is affecting their work but a requesting data change , a new hardware or software from the catalog. This will not be considered new incident but a service request.<description_end>", "matched_intent_sys_id": "f263409e1b4a4b10efc9a609b04bcb5d" } ...'

4) Created a new subflow to plug this into the process. Defined inputs ( as inbound email sys_id), expected output variable as 'intent' ( type: Dynamic Content) and also the subflow output ( as Agent Output). While testing, the issue is that the Agent Output is not getting set based on the execution.

(check the screenshot below)

pariknarain_0-1784072882538.png

The Agent Status does populate as 'Success'. But the 'Agent Output' is not being set and I'd like to understand why. It seems this API sets the value but I cannot find any references to this in developer documentation. sn_fd_genai.FlowDesignerGenAIUtil().getTransformedAgentOutput(fd_data._1__use_an_ai_agent_step.execution_plan_record, fd_data.action_inputs.wait_for_completion).output;

 

Any pointers will be appreciated.

 

The  Execution Plan (below) also shows successful execution for all expected steps, and the requirement is to extract the full JSON Output from here (and parse) for next steps.

pariknarain_1-1784073249090.png

 

3 REPLIES 3

Vikram Reddy
Tera Guru

Hey @pariknarain,

 

// Script step, right after the "Use an AI Agent" action

var epId = fd_data._1__use_an_ai_agent_step.execution_plan_record;

var task = new GlideRecord('sn_aia_execution_task');
task.addQuery('execution_plan', epId);
task.addQuery('status', 'Success');
task.orderByDesc('order');
task.setLimit(1);
task.query();

var intentResult = {};
if (task.next()) {
    var raw = task.getValue('output');
    var match = raw.match(/\{[\s\S]*\}/);
    if (match) {
        intentResult = JSON.parse(match[0]);
    }
}

// map intentResult.intent and intentResult.matched_intent_sys_id
// to your subflow outputs instead of relying on "Agent Output"

Stop chasing the Custom Schema mapping, it's failing silently, not your flow logic. That formula you dug up, sn_fd_genai.FlowDesignerGenAIUtil().getTransformedAgentOutput, is the internal helper the platform itself uses to try to coerce the agent's final text into whatever schema you defined under Expected outputs. There's no dev doc for it because it was never meant to be called directly, it's plumbing behind Agent Output and Agent Message, not a supported API.

The real issue is what the agent actually hands back. Your manual test output isn't valid JSON on its own, it's a natural-language wrapper with a JSON blob buried inside it ("Output : **MATCHED INTENTS** : {...}"). When Expected outputs is set to Custom Schema, that transform tries to parse the whole string against your schema, can't get a clean match, and instead of erroring out it just returns nothing. That's exactly why Agent Status reads Success in your screenshot, the agent run itself was fine, while both Agent Output and Agent Message sit blank right next to it, they're both populated by that same failing transform call.

So skip the schema mapping and go straight to the source:

  1. Set Expected outputs back to Dynamic Content instead of Custom Schema.
  2. Add a script step that queries sn_aia_execution_task for the most recent Success row under that execution plan, this is the same table your Execution Plan's Execution Tasks related list reads from, and your organize_general_knowledge row at order 800 already has the full MATCHED INTENTS text sitting in its Output field.
  3. Regex the JSON block out of that text and JSON.parse it, then map the result onto your subflow outputs.

Field names above match what I could confirm from the execution task list columns, double check they line up exactly on your instance version.

 

Thank you,
Vikram Karety
Octigo Solutions INC

Thanks Vikram, Thank you for this. Being old school I was thinking of going back to the source directly...will try and get back! 

I added a new script action to execute the above script. But the value of intent and intent sys id are not being found. Possibly due to the dynamic content. 

outputs.intent = intentResult.intent;
outputs.intent_id = intentResult.matched_intent_sys_id
 
Here's the Output within the execution task from where these have to be extracted by the script:
{"result":"1. ALL CANDIDATES:\n - intent_sys_id: f263409e1b4a4b10efc9a609b04bcb5d\n evidence: \"Can you please update my name as it appears on my outlook email and Teams to Kate McLoughlin.\"\n\n2. Intent Analysis:\n - f263409e1b4a4b10efc9a609b04bcb5d\n Identified Portion: \"Can you please update my name as it appears on my outlook email and Teams to Kate McLoughlin. I do not go by Kaitlin and it’s causing some confusion.\"\n Evaluation:\n Subject: ✓ — The sender is requesting a change for herself, which aligns with the intent's user-focused service request framing.\n Action: ✓ — The sender explicitly requests a data change, not issue reporting or general help.\n Detail: ✓ — The relevant details describe a name change on Outlook and Teams, which fits the intent's data-change/service-request scope without contradiction.\n Directness: ✓ — The request is explicit and directly asks for the update.\n Clarity: ✓ — The intent is unambiguous: change the displayed name to Kate McLoughlin.\n Verdict Line:\n f263409e1b4a4b10efc9a609b04bcb5d — Subject:✓ Action:✓ Detail:✓\n Directness:✓ Clarity:✓ → MATCH\n\n3. Verification of Intent Analysis:\n - Goal 1: **Update the displayed name on Outlook email and Teams to Kate McLoughlin**\n Portion analysed for intents: \"Can you please update my name as it appears on my outlook email and Teams to Kate McLoughlin. I do not go by Kaitlin and it’s causing some confusion.\"\n - Verification Confirmed: All identified latest-sender goals were evaluated completely with no pending goal left unanalyzed.\n\n4. Final Matched-Intent Result:\n **MATCHED INTENTS** : [{\n \"intent\": \"<description_start>The user is not reporting an issue which is affecting their work but a requesting data change , a new hardware or software from the catalog. This will not be considered new incident but a service request.<description_end>\",\n \"matched_intent_sys_id\": \"f263409e1b4a4b10efc9a609b04bcb5d\"\n }]\n COMMENTS: The email is a clear, direct self-request to update the sender’s displayed name in Outlook and Teams. It matches the service-request/data-change intent on subject, action, relevant details, directness, and clarity. Verification completed and reasoning checked for contradictions.\n Number of Matched Intents: 1"}