import { createZapierSdk } from "@zapier/zapier-sdk"; const sdk = createZapierSdk(); const app = "__ZAPIER_SDK_SLACK_APP__"; const connection = "__ZAPIER_SDK_SLACK_CONNECTION__"; const email = "__ZAPIER_SDK_ACCOUNT_EMAIL__"; async function main(): Promise { const { data: [user], } = await sdk.runAction({ app, actionType: "search", action: "user_by_email", connection, inputs: { email }, }); const userId = (user as { id?: unknown } | undefined)?.id; if (typeof userId !== "string") { throw new Error("Slack user lookup did not return a user ID."); } await sdk.runAction({ app, actionType: "write", action: "direct_message", connection, inputs: { channel: userId, text: "Hello via Zapier SDK" }, }); console.log("Slack DM sent."); } main().catch((error: unknown) => { console.error(error); process.exitCode = 1; });