Creating Plot Twists
    Preparing search index...

    Type Alias Action

    Action:
        | { type: external; title: string; url: string }
        | { type: conferencing; url: string; provider: ConferencingProvider }
        | {
            type: auth;
            title: string;
            provider: string;
            scopes: string[];
            callback: Callback;
        }
        | { type: callback; title: string; callback: Callback }
        | {
            type: file;
            fileId: string;
            fileName: string;
            fileSize: number;
            mimeType: string;
            imageWidth?: number | null;
            imageHeight?: number | null;
        }
        | {
            type: fileRef;
            ref: string;
            fileName: string;
            fileSize: number
            | null;
            mimeType: string;
            imageWidth?: number | null;
            imageHeight?: number | null;
            contentId?: string | null;
        }
        | { type: thread; threadId: Uuid }
        | {
            type: plan;
            title: string;
            operations: PlanOperation[];
            callback: Callback;
            approved?: boolean;
            results?: PlanOperationResult[];
        }
        | { type: chat; title: string; url: string; callback: Callback }

    Represents a clickable action attached to a thread.

    Thread actions are rendered as buttons that enable user interaction with threads. Different action types have specific behaviors and required fields for proper functionality.

    Type Declaration

    • { type: external; title: string; url: string }
      • type: external

        External web link that opens in browser

      • title: string

        Display text for the action button

      • url: string

        URL to open when clicked

    • { type: conferencing; url: string; provider: ConferencingProvider }
      • type: conferencing

        Video conferencing action with provider-specific handling

      • url: string

        URL to join the conference

      • provider: ConferencingProvider

        Conferencing provider for UI customization

    • {
          type: auth;
          title: string;
          provider: string;
          scopes: string[];
          callback: Callback;
      }
      • type: auth

        Authentication action that initiates an OAuth flow

      • title: string

        Display text for the auth button

      • provider: string

        OAuth provider (e.g., "google", "microsoft")

      • scopes: string[]

        Array of OAuth scopes to request

      • callback: Callback

        Callback token for auth completion notification

    • { type: callback; title: string; callback: Callback }
      • type: callback

        Callback action that triggers a twist method when clicked

      • title: string

        Display text for the callback button

      • callback: Callback

        Token identifying the callback to execute

    • {
          type: file;
          fileId: string;
          fileName: string;
          fileSize: number;
          mimeType: string;
          imageWidth?: number | null;
          imageHeight?: number | null;
      }
      • type: file

        File attachment action stored in R2

      • fileId: string

        Unique identifier for the stored file

      • fileName: string

        Original filename

      • fileSize: number

        File size in bytes

      • mimeType: string

        MIME type of the file

      • OptionalimageWidth?: number | null

        Intrinsic width of the image in pixels (only for image files)

      • OptionalimageHeight?: number | null

        Intrinsic height of the image in pixels (only for image files)

    • {
          type: fileRef;
          ref: string;
          fileName: string;
          fileSize: number | null;
          mimeType: string;
          imageWidth?: number | null;
          imageHeight?: number | null;
          contentId?: string | null;
      }
      • type: fileRef

        Reference to an attachment hosted by a connector's source system

      • ref: string

        Opaque identifier interpreted only by the owning connector

      • fileName: string

        Display filename

      • fileSize: number | null

        File size in bytes if known

      • mimeType: string

        MIME type

      • OptionalimageWidth?: number | null

        Intrinsic width of the image in pixels (only for image files)

      • OptionalimageHeight?: number | null

        Intrinsic height of the image in pixels (only for image files)

      • OptionalcontentId?: string | null

        Content-ID of an inline body image, without the angle brackets — the value a cid: reference in the note's content resolves against.

        Set this ONLY when the note's content still references the part (an <img src="cid:…"> that survived quote-trimming). Plot then renders the image in the body where the sender placed it, at its own size, instead of appending an attachment chip.

        Leave it unset for ordinary attachments. An inline part the retained content no longer references — a signature logo left behind when a quoted reply was trimmed — should be dropped entirely rather than emitted with a contentId, since nothing in the body points at it.

    • { type: thread; threadId: Uuid }
      • type: thread

        Thread reference action for navigating to a related thread

      • threadId: Uuid

        UUID of the referenced thread

    • {
          type: plan;
          title: string;
          operations: PlanOperation[];
          callback: Callback;
          approved?: boolean;
          results?: PlanOperationResult[];
      }
      • type: plan

        Structured plan of operations for user approval

      • title: string

        Human-readable summary of the plan

      • operations: PlanOperation[]

        Operations to execute on approval

      • callback: Callback

        Callback invoked with (action, approved: boolean) after the user decides

      • Optionalapproved?: boolean

        The user's decision. Set by the server when the action is delivered to the plan callback; absent on the action the twist created.

      • Optionalresults?: PlanOperationResult[]

        Per-operation execution results, same order as operations. Set by the server when approved is true: operations are executed server-side BEFORE the callback is invoked.

    • { type: chat; title: string; url: string; callback: Callback }
      • type: chat

        Starts a realtime conversation with the twist — spoken, typed, or both. The conversation's turns are written into the thread as notes.

      • title: string

        Display text for the chat button

      • url: string

        Fallback URL for clients that predate chat support. Such clients coerce unknown action types to external and open this instead, so it must be a working link to the thread. The runtime fills it in.

      • callback: Callback

        Token for the twist method that returns the session's NewChatSpec. Resolved when the user taps, not when the note was written, so a stale note still opens a current conversation.

    // External action - opens URL in browser
    const externalAction: Action = {
    type: ActionType.external,
    title: "Open in Google Calendar",
    url: "https://calendar.google.com/event/123",
    };

    // Conferencing action - opens video conference with provider info
    const conferencingAction: Action = {
    type: ActionType.conferencing,
    url: "https://meet.google.com/abc-defg-hij",
    provider: ConferencingProvider.googleMeet,
    };

    // Integrations action - initiates OAuth flow
    const authAction: Action = {
    type: ActionType.auth,
    title: "Continue with Google",
    provider: AuthProvider.Google,
    scopes: ["https://www.googleapis.com/auth/calendar.readonly"],
    callback: "callback-token-for-auth-completion"
    };

    // Callback action - triggers a twist method
    const callbackAction: Action = {
    type: ActionType.callback,
    title: "📅 Primary Calendar",
    token: "callback-token-here"
    };