import { createZapierSdk } from "@zapier/zapier-sdk";
const zapier = createZapierSdk();
// Get the user's connected apps
const { data: slackAuth } = await zapier.findFirstAuthentication({
appKey: "slack",
owner: "me",
});
// Define tools for your AI agent
const tools = [
{
name: "send_slack_message",
description: "Send a message to a Slack channel",
parameters: {
channel: { type: "string", description: "Channel name or ID" },
message: { type: "string", description: "Message to send" },
},
execute: async ({ channel, message }) => {
const { data } = await zapier.apps.slack.write.send_channel_message({
inputs: { channel, text: message },
authenticationId: slackAuth.id,
});
return data;
},
},
{
name: "create_calendar_event",
description: "Create a Google Calendar event",
execute: async ({ title, startTime, endTime }) => {
const { data: calAuth } = await zapier.findFirstAuthentication({
appKey: "google-calendar",
owner: "me",
});
const { data } = await zapier.apps.google_calendar.write.create_event({
inputs: { summary: title, start: startTime, end: endTime },
authenticationId: calAuth.id,
});
return data;
},
},
];
// Your AI agent can now use these tools based on user requests