- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
Does anyone has experience of invoking an AI agent from a script such as script include, business rule etc ? Is there an API existing for this ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Not for an AI Agent specifically, but for an Agentic Workflow, you can do this:
var request = {
targetRecordId: "25b65a1c936339100c8a30118bba10c7",
targetTable: "incident",
usecaseId: "78c687369f19d2d02b2d1597d90a1c97",
conversationUser: "46d44a23a9fe19810012d100cca80666",
objective: "Help me resolve the incident INC0010252",
conversationLabel: "INC0010252: Incident Resolution"
};
var aiAgentRuntimeUtil = new AiAgentRuntimeUtil();
var response = aiAgentRuntimeUtil.startAiAgentConversation(request);
gs.info(JSON.stringify(response));
Also discussed here:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited Tuesday
Hi @karthiknarl ,
"Use an AI agent" action in Flow Designer / Workflow Studio.
From a Script Include, Business Rule, or UI Action, you can call a Flow that contains the AI Agent action. Example syntax:
// Example: Trigger a flow from a Business Rule
var inputs = {
short_description: current.short_description,
sys_id: current.sys_id
};
sn_fd.FlowAPI.getRunner()
.flow('your_flow_sys_id_or_name')
.inForeground()
.withInputs(inputs)
.run();This way, your script indirectly invokes the AI Agent by running the flow that contains it.
refer https://developer.servicenow.com/dev.do#!/reference/api/xanadu/server/ScriptableFlowRunnerScopedAPI
https://developer.servicenow.com/dev.do#!/reference/api/xanadu/server/sn_fd-namespace/ScriptableFlow...
Example: Use an AI agent
You can define triggers for Agentic Workflows and AI Agents - not only via chat, but also programmatically through APIs, GlideRecord queries, or Scripted REST APIs:
refer this thread - Trigger options for Agentic Workflow or AI Agent
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @karthiknarl ,
So far ServiceNow not release any API directly. There is another thread which will help for you.
Please check : https://www.servicenow.com/community/now-assist-forum/trigger-options-for-agentic-workflow-or-ai-age...
Please mark helpful and correct answer if it's worthy for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Not for an AI Agent specifically, but for an Agentic Workflow, you can do this:
var request = {
targetRecordId: "25b65a1c936339100c8a30118bba10c7",
targetTable: "incident",
usecaseId: "78c687369f19d2d02b2d1597d90a1c97",
conversationUser: "46d44a23a9fe19810012d100cca80666",
objective: "Help me resolve the incident INC0010252",
conversationLabel: "INC0010252: Incident Resolution"
};
var aiAgentRuntimeUtil = new AiAgentRuntimeUtil();
var response = aiAgentRuntimeUtil.startAiAgentConversation(request);
gs.info(JSON.stringify(response));
Also discussed here:
