Creating Plot Twists
    Preparing search index...

    Class IntegrationsAbstract

    Built-in tool for managing OAuth authentication and channel resources.

    The Integrations tool:

    1. Manages channel resources (calendars, projects, etc.) per actor
    2. Returns tokens for the user who enabled sync on a channel
    3. Supports per-actor auth via actAs() for write-back operations
    4. Provides saveLink/saveContacts for Connectors to save data directly

    Connectors declare their provider, scopes, and channel lifecycle methods as class properties and methods. The Integrations tool reads these automatically. Auth and channel management is handled in the twist edit modal in Flutter.

    class CalendarConnector extends Connector<CalendarConnector> {
    readonly provider = AuthProvider.Google;
    readonly scopes = ["https://www.googleapis.com/auth/calendar"];

    build(build: ToolBuilder) {
    return {
    integrations: build(Integrations),
    };
    }

    async getChannels(auth: Authorization, token: AuthToken): Promise<Channel[]> {
    const calendars = await this.listCalendars(token);
    return calendars.map(c => ({ id: c.id, title: c.name }));
    }

    async onChannelEnabled(channel: Channel) {
    // Start syncing
    }

    async onChannelDisabled(channel: Channel) {
    // Stop syncing
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Merge scopes from multiple tools, deduplicating.

      Parameters

      • ...scopeArrays: string[][]

        Arrays of scopes to merge

      Returns string[]

      Deduplicated array of scopes

    • Retrieves an access token for a channel resource.

      Returns the token of the user who enabled sync on the given channel. If the channel is not enabled or the token is expired/invalid, returns null.

      Parameters

      • channelId: string

        The channel resource ID (e.g., calendar ID)

      Returns Promise<AuthToken | null>

      Promise resolving to the access token or null

    • Retrieves an access token for a channel resource.

      Parameters

      • provider: AuthProvider

        The OAuth provider (deprecated, ignored for single-provider connectors)

      • channelId: string

        The channel resource ID (e.g., calendar ID)

      Returns Promise<AuthToken | null>

      Promise resolving to the access token or null

      Use get(channelId) instead. The provider is implicit from the connector.

    • Execute a callback as a specific actor, requesting auth if needed.

      If the actor has a valid token, calls the callback immediately with it. If the actor has no token, creates a private auth note in the specified activity prompting them to connect. Once they authorize, this callback fires.

      Type Parameters

      Parameters

      • provider: AuthProvider

        The OAuth provider

      • actorId: ActorId

        The actor to act as

      • activityId: Uuid

        The activity to create an auth note in (if needed)

      • callback: TCallback

        Function to call with the token

      • ...extraArgs: TArgs

        Additional arguments to pass to the callback

      Returns Promise<void>

    • Saves a link with notes to the connector's priority.

      Creates a thread+link pair. The thread is a lightweight container; the link holds the external entity data (source, meta, type, status, etc.).

      This method is available only to Connectors (not regular Twists).

      Parameters

      Returns Promise<Uuid | null>

      Promise resolving to the saved thread's UUID, or null if the link was filtered out (e.g. older than the plan's sync history limit)

    • Archives links matching the given filter that were created by this connector.

      For each archived link's thread, if no other non-archived links remain, the thread is also archived.

      Parameters

      Returns Promise<void>

      Promise that resolves when archiving is complete

    • Sets or clears todo status on a thread owned by this connector.

      Parameters

      • source: string

        The link source URL identifying the thread

      • actorId: ActorId

        The user to set the todo for

      • todo: boolean

        true to mark as todo, false to clear/complete

      • Optionaloptions: { date?: string | Date }

        Additional options

        • Optionaldate?: string | Date

          The todo date (when todo=true). Defaults to today.

      Returns Promise<void>