Agent Auto Trigger

The Auto Trigger feature enables you to automate the initiation of a job at regular intervals. This functionality is designed for scenarios where periodic execution of tasks is required. Below is a co

Setting Up an Auto Trigger Session

To initiate an auto-triggered session, use the following example:

// Start a session with auto trigger
// Auto trigger every 30 minutes, ending at 2025-01-20T00:00:00Z, starting at 2025-01-29T00:00:00Z, and sending a webhook to https://example.com/webhook

const session = await assisfy.session().create({
    goal: "Go through https://assisfy.ai/blog and let me know the latest update on the blog",
    withAutoTrigger: {
        interval: 30, // Interval in minutes
        end_at: '2025-01-20T00:00:00Z',
        start_now: true, // if true, the session will start immediately, change to false if you want to start at a specific time
        web_hook_url: 'https://example.com/webhook',
    }
});

// The session creation will respond with an object similar to:
{
    goal // your agent's goal
    email // your current email
    config // your agent's api config
    max_session_per_day // max session per day you have set
    today_sessions // sessions your agent has ran today
    sessions_left // available sessions that can be triggered
    auto_trigger_tracking_id // tracking id for auto-triggered agents
    auto_trigger_web_hook_url // your webhook url
    auto_trigger_web_hook_signature // webhook signature that is done
}

Handling Webhook Events

When using auto-trigger, webhook events are used to track the progress and activities of your session. Since socket sessions are not utilized in this mode, you must rely on webhook events for updates. Below is the list of events you may receive:

  • trigger.session.started: Triggered when a new session is started. This includes the session ID.

  • trigger.action.run: Indicates that an action is being executed.

  • trigger.external.resource.requested: Signals a request for external resources.

  • trigger.thoughts.and.memories: Logs thoughts and memories generated by the session.

  • trigger.browser.started: Indicates the start of browser-related activities.

  • trigger.complete: Denotes session completion.

  • trigger.error: Reports any errors encountered during the session.

Webhook Event Example

Your webhook will receive event payloads similar to the following:

{
    "event": "trigger.action.run",
    "data": {
        "...other data information": "...",
        sessionId
        tracking_id
    }
}

Key Considerations

  1. Session Start and End Times:

    • Ensure the start_at and end_at times are correctly set in ISO 8601 format.

    • The interval should be specified in minutes.

  2. Webhook URL:

    • The web_hook_url should be a publicly accessible endpoint capable of receiving and processing events.

  3. Handling Resource Requests:

    • Manage external resource requests efficiently by responding to events like external_resource_requested based on the resource_type.

Supported Resource Types

  • admin_permission_request: Requests requiring administrative approval.

  • request_user_input: Requests requiring user-provided input.

By following this guide, you can effectively leverage the Auto Trigger feature for automating tasks and integrating seamlessly with your workflows.

Last updated