Skip to main content

Connect OpenAI or Claude

Agent Flow schema and MCP server are preview features

Agent flow schema and hosted MCP servers are preview features that require Prismatic Support to enable the feature for you. Please contact Prismatic Support if you'd like to opt-in to the MCP Preview.

After creating flows that include flow invocation schema, you can consume those flows from an AI agent. AI agents like OpenAI or Claude refer to invocable functions as tools.

OpenAI example

After querying for agent flows using Prismatic's API, you can feed those agent flows into OpenAI using the openai library's responses.create function, like this:

Consume agent flows from OpenAI
function convertToOpenAITools(nodes) {
return nodes.map((node) => {
const schema = JSON.parse(node.invokeSchema);
// Add required array if properties exist but required doesn't
if (schema.properties && !schema.required) {
schema.required = Object.keys(schema.properties);
}

return {
type: "function",
function: {
name: node.name.toLowerCase().replace(/\s+/g, "_"),
description: node.description,
parameters: schema,
},
};
});
}

const openai = new OpenAI({ apiKey: "your-api-key" });
const tools = convertToOpenAITools(jsonResponse.data.ai.agentFlows.nodes);

const response = await openai.responses.create({
model: "gpt-4o",
input: "Get John Smith's contact information from the CRM",
tools: tools,
tool_choice: "auto",
});

Then you will need to observe if the response has any of type tool_call and then fetch the webhookUrl of the corresponding name.

Anthropic / Claude example

After querying for agent flows using Prismatic's API, you can feed those agent flows into Anthropic using the openai library's responses.create function, like this:

Consume agent flows from Anthropic / Claude
function convertToAnthropicTools(nodes) {
return nodes.map((node) => {
const schema = JSON.parse(node.invokeSchema);
// Ensure required array exists
if (schema.properties && !schema.required) {
schema.required = Object.keys(schema.properties);
}

return {
name: node.name.toLowerCase().replace(/\s+/g, "_"),
description: node.description,
input_schema: schema,
};
});
}

const anthropic = new Anthropic({ apiKey: "your-api-key" });
const tools = convertToAnthropicTools(jsonResponse.data.ai.agentFlows.nodes);

const response = await anthropic.messages.create({
model: "claude-3-opus-20240229",
messages: [
{
role: "user",
content: "Get John Smith's contact information from the CRM",
},
],
tools: tools,
tool_choice: { type: "auto" },
});

Then you will need to observe if the response has any of type tool_use and then fetch the webhookUrl of the corresponding name.