Code-native agentic flows
This guide walks you through setting up a code-native integration flow so that AI agents can invoke it as a tool. Before you begin, review flow invocation schemas to understand the schema format.
Add an invocation schema to a flow
To add a flow invocation schema to a code-native flow, add a schemas.invoke property to your flow definition.
You must also set isAgentFlow: true on the flow definition.
In this example, we define a flow that searches for people in Acme CRM by first and last name.
The invocation schema expects two optional string properties, first and last.
Example code-native flow with invocation schema
import { flow } from "@prismatic-io/spectral";
import axios from "axios";
export const searchPeople = flow({
name: "Search People",
stableKey: "search-people",
description: "Search for People in Acme CRM",
isAgentFlow: true,
schemas: {
invoke: {
$schema: "https://json-schema.org/draft/2020-12/schema",
$comment:
"Given a first and last name of a person, search for matching people in Acme CRM",
properties: {
first: {
description: "A person's first name",
type: "string",
},
last: {
description: "A person's last name",
type: "string",
},
},
title: "search-people-in-acme",
type: "object",
},
},
isSynchronous: true,
onExecution: async (context, params) => {
const { first: firstNameSearch, last: lastNameSearch } = params.onTrigger
.results.body.data as { first: string; last: string };
const { data: people } = await axios.get<{ name: string }[]>(
"https://jsonplaceholder.typicode.com/users",
);
const matchingPeople = people.filter((person) => {
const [firstName, lastName] = person.name.split(" ");
if (firstNameSearch) {
if (!firstName.toLowerCase().includes(firstNameSearch.toLowerCase())) {
return false;
}
}
if (lastNameSearch) {
if (!lastName.toLowerCase().includes(lastNameSearch.toLowerCase())) {
return false;
}
}
return true;
});
return { data: matchingPeople };
},
});
export default [searchPeople];
Setting isAgentFlow: true automatically marks the flow as tool-enabled.
Once deployed, you can query for the flow's invocation schema and connect it to an AI agent.