On Email Intent Indentification agent -Agent Output is not available in the flow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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)
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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:
- Set Expected outputs back to Dynamic Content instead of Custom Schema.
- 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.
- 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks Vikram, Thank you for this. Being old school I was thinking of going back to the source directly...will try and get back!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
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.