> ## Documentation Index
> Fetch the complete documentation index at: https://docs.automate.ax/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Trigger workspace agent

> Start a published ChatGPT Workspace Agent run from an automation.

`triggerChatGPTWorkspaceAgent` queues a published ChatGPT Workspace Agent through its API channel.

```ts automations/trigger-chatgpt-agent.automation.ts theme={null}
import { automation, onHttpRequest } from "automate.ax"
import { triggerChatGPTWorkspaceAgent } from "automate.ax/chatgpt"

export default automation("Start ChatGPT agent", () => {
  const request = onHttpRequest({ scope: "automation" })
  const run = triggerChatGPTWorkspaceAgent({
    apiTriggerId: "agtch_engineering_123",
    conversationKey: request.headers["x-thread-id"],
    idempotencyKey: request.headers["x-event-id"],
    input: "Review the latest engineering request and implement it.",
  })

  run.runId
  run.conversationUrl
})
```

`apiTriggerId` is the stable `agtch_` identifier shown for the agent's published API channel. `input` is the message sent to the agent. Optional `conversationKey` continues the same agent conversation across related events. Optional `idempotencyKey` prevents a retry of the same event from adding a second trigger. Optional second argument `{ account }` defaults to the project binding.

The action returns the `apirun_` run ID and ChatGPT conversation URL after ChatGPT accepts the run. Use `getChatGPTWorkspaceAgentRun` to poll its status. ChatGPT does not currently expose the agent's response through this API.

Connect ChatGPT with a Workspace Agent access token created in **ChatGPT workspace settings > Access tokens** with the **Workspace Agents** scope. A workspace administrator must first enable Workspace agents and personal access tokens.
