Automate ChatGPT with TypeScript
Trigger published ChatGPT Workspace Agents, continue related conversations, and inspect each run's status from an automation.
import { automation, onHttpRequest, sendEmail, t } from "automate.ax"
import { chatgpt } from "automate.ax/chatgpt"
import { z } from "zod"
export default automation("Run ChatGPT agent", () => {
const request = onHttpRequest({
body: z.object({ message: z.string() }),
scope: "automation",
})
const run = chatgpt.runWorkspaceAgent({
apiTriggerId: "agtch_engineering_123",
conversationKey: request.headers["x-thread-id"],
idempotencyKey: request.headers["x-event-id"],
input: request.body.message,
})
sendEmail({
subject: t`ChatGPT agent ${run.status}`,
text: run.conversationUrl,
})
})What you can do
Actions
- Trigger published Workspace Agents
- Continue related agent conversations
- Prevent duplicate runs with idempotency keys
- Wait durably for completion or failure
- Inspect run status and conversation links
Triggers
No provider trigger is published for ChatGPT yet. Use another trigger, then call its actions.