Skip to main content

Triggers & Webhooks

What triggers are​

Triggers let external events start AI Partner goals automatically. You configure a trigger once, and every time the event fires, AI Partner runs the associated goal — no prompt from you needed.

Three trigger types:

TypeFires whenExample
Email triggerA new email arrives matching your filterNew email from investor → goal: "draft a reply in my voice"
Calendar triggerA calendar event starts or is about to startMeeting in 5 minutes → goal: "brief me on who's attending"
WebhookAn external service POSTs to your endpointGitHub issue created → goal: "triage and assign this issue"

Email triggers​

Setup​

Connect your mailbox in System → Integrations → Gmail, then turn on Email Trigger in the same place and set how often it should check for new mail.

How to configure​

Go to Settings → Triggers → + New Email Trigger:

Name: Investor email handler
Filter:
From: *@sequoia.com OR *@accel.com OR *@tiger.com
Subject contains: (any)
Has attachment: (any)

Goal template:
A new email arrived from {{sender}} with subject "{{subject}}".
Draft a professional reply in Alex's voice acknowledging their message
and moving toward next steps. Send the draft to my Telegram for approval.

Run mode: Goal

Filter syntax (Gmail query syntax — same as the Gmail search box):

  • from:boss@co.com — match a sender; from:*@sequoia.com for a domain
  • subject:urgent — match subject keyword
  • `

What happens​

New email arrives in Gmail
↓
EmailTriggerService polls Gmail every 5 minutes
↓
Email matches your filter? → yes
↓
Template substituted → goal created
↓
The goal engine runs the goal
↓
Result delivered to Telegram/chat

Template variables​

  • {{sender}} — From address of the matching email
  • {{subject}} — Email subject line
  • {{snippet}} — Short preview of the email body (~100 chars)
  • {{attachments}} — Newline-separated workspace paths of downloaded files (only present when fetchAttachments: true)

Fetching attachments​

Set fetchAttachments: true when creating the trigger via the API to have AI Partner download email attachments into the tenant workspace before the goal runs:

{
"name": "Client statements",
"filter": "from:client@co.com has:attachment",
"fetchAttachments": true,
"mode": "goal",
"taskTemplate": "New bank statements received. Files:\n{{attachments}}\nRun month-end close for these statements."
}

Files are saved to uploads/email/<message_id>/ in the tenant workspace and their paths are injected into {{attachments}} (newline-separated) before the goal starts. This is the mechanism used by the bookkeeping service pilot to receive client CSV statements.


Calendar triggers​

Setup​

Connect Google Calendar in System → Integrations, then turn on Calendar Trigger.

How to configure​

Go to Settings → Triggers → + New Calendar Trigger:

Name: Pre-meeting brief
Trigger: 15 minutes before any event with "meeting" or "call" in the title

Goal template:
I have a meeting starting in 15 minutes: "{{event_title}}" with {{attendees}}.
Briefly research each attendee (LinkedIn, recent news).
Summarize what I should know before the call. Send to my Telegram.

Run mode: Goal

Template variables:

  • {{event_title}} — calendar event title
  • {{attendees}} — list of attendee email addresses
  • {{location}} — meeting URL or room
  • {{start_time}} — event start time
  • {{description}} — event description

Timing options:

  • Fire at event start
  • Fire N minutes before
  • Fire N minutes after event ends (for follow-up goals)

Webhooks​

Webhooks let any external service trigger an AI Partner goal by sending an HTTP POST request to your webhook URL.

Creating a webhook​

Go to Settings → Triggers → + New Webhook:

Name: GitHub new issue
Endpoint path: /api/triggers/webhook/github-issue (auto-generated)
Secret token: (auto-generated, copy this to GitHub)

Goal template:
A new GitHub issue was created:
Title: {{payload.issue.title}}
Body: {{payload.issue.body}}
Author: {{payload.issue.user.login}}
Repo: {{payload.repository.full_name}}

Triage this issue: assign a priority label (P0/P1/P2/P3),
assign to the right team (@backend or @frontend), and add a comment
acknowledging the reporter.

Run mode: Goal

Your webhook URL:

https://your-domain.com/api/triggers/webhook/github-issue

Set this in GitHub → repo → Settings → Webhooks → Payload URL.

Security: the secret token is used to validate the X-Hub-Signature-256 header. Requests without a valid signature are rejected.

Template variables​

The entire webhook payload is available as {{payload.*}}. Use dot notation to access nested fields:

{{payload.issue.title}}
{{payload.pull_request.html_url}}
{{payload.pusher.name}}
{{payload.commits.0.message}}

Run history​

Every webhook trigger logs:

  • When it fired
  • The raw payload received
  • The goal that was started
  • The goal's result

Go to Settings → Triggers → [webhook name] → Run History to see the log.


Managing triggers​

ActionHow
Enable / DisableToggle in the triggers list
Test manuallyClick Test — runs the goal with dummy/last payload
View run historyClick the trigger → History tab
Edit templateClick the pencil icon
DeleteClick the trash icon — removes future runs (history is kept)

Trigger vs. Task Scheduler vs. Heartbeat​

TriggerTask SchedulerHeartbeat
Fires whenExternal event (email, calendar, HTTP)Fixed cron scheduleIntelligent tick based on context
Initiated byExternal systemClockAI Partner itself
Goal definedPer-trigger templatePer-task messageLLM-decided each tick
Best forReactive automationPredictable recurring jobsProactive intelligence

Use all three together for full automation coverage:

  • Triggers for reacting to the outside world
  • Task Scheduler for predictable recurring jobs
  • Heartbeat for intelligent gap-filling

Example: full email automation pipeline​

1. Email trigger: new email from client
↓
Goal: classify intent + draft reply
↓
AUTHORITY.md: reply_email + counterparty:client → draft_and_ask
↓
Telegram: approval request sent
↓
You tap "Approve"
↓
Email sent; counterparty record updated

2. Calendar trigger: 15 min before client meeting
↓
Goal: brief me on this client
↓
Pulls CounterpartyStore record (last contact, open commitments)
↓
Searches episodic memory for prior meeting transcripts
↓
Sends 2-paragraph brief to Telegram

3. Calendar trigger: 5 min after meeting ends
↓
Goal: send follow-up email
↓
Loads transcript from workspace/meetings/
↓
Drafts follow-up with action items
↓
Telegram approval → send