Triggers
A trigger runs an agent automatically, on a time schedule or when an event fires in a connected integration.
Each trigger sends the same input to the agent every time it fires. You create it with aix.Trigger(...).save(), and pause, resume or delete it like any other asset.
Try it
from aixplain import Aixplain
aix = Aixplain(api_key="YOUR_API_KEY")
agent = aix.Agent(
name="Ops assistant",
description="Writes short operational digests.",
instructions="You are a helpful operations assistant. Be brief.",
).save()
daily = aix.Trigger(
name="Daily digest",
agent=agent,
input="Summarize today's priorities in three bullets.",
every="day",
at="09:00",
timezone="Europe/London",
).save()
print(daily.id is not None, daily.schedule_type, daily.enabled)
The agent now runs every day at 09:00 London time. You describe the schedule in plain arguments; the SDK builds it for you.
Set a time schedule
Use run_at for a single run, or every for a repeating one. Add at for the time of day and on for days of the week or month.
once = aix.Trigger(
name="Launch reminder", agent=agent, input="Remind the team about the launch.",
run_at="2027-01-26T12:00:00Z",
).save()
every_two_hours = aix.Trigger(
name="Queue check", agent=agent, input="Check the support queue.",
every="hour", interval=2,
).save()
weekly = aix.Trigger(
name="Weekly report", agent=agent, input="Compile the weekly report.",
every="week", on=["mon", "thu"], at="17:00",
).save()
monthly = aix.Trigger(
name="Invoice run", agent=agent, input="List the invoices to send.",
every="month", on=[1, 15], at="09:00",
).save()
for trigger in (once, every_two_hours, weekly, monthly):
print(trigger.name, "->", trigger.schedule_type)
| Arguments | schedule_type |
|---|---|
run_at=<ISO timestamp> | once |
every="minute" or "hour", with interval | recurring |
every="day", at=... | daily |
every="week", on=[weekdays], at=... | weekly |
every="month", on=[days of month], at=... | monthly |
Fire on an event
An event trigger runs the agent when something happens in a connected integration, such as a new email. Browse the events an integration offers with .triggers, the same way you browse .actions.
gmail = aix.Integration.get("composio/gmail/composio")
print(list(gmail.triggers))
To create the trigger, get a tool you have already connected to that integration and pick the event from its triggers. See Integrations to connect one.
GMAIL_TOOL_ID = "YOUR_GMAIL_TOOL_ID" # from tool.id after you connect Gmail
gmail_tool = aix.Tool.get(GMAIL_TOOL_ID)
triage = aix.Trigger(
name="Triage inbox",
agent=agent,
input="Triage this email and flag anything urgent.",
event=gmail_tool.triggers["GMAIL_NEW_GMAIL_MESSAGE"],
).save()
Event triggers report trigger_type as external. Time triggers report time.
Manage triggers
List an agent's triggers, pause and resume one with enabled, and delete it.
page = aix.Trigger.search(agent=agent)
print("triggers:", len(page.results))
daily.enabled = False
daily.save()
print("enabled:", aix.Trigger.get(daily.id).enabled)
daily.enabled = True
daily.save()
for trigger in page.results:
trigger.delete()
print("left:", len(aix.Trigger.search(agent=agent).results))
Deleting an event trigger also deactivates the event on the connected integration.
Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | required | Display name. |
agent | Agent | required | The agent to run. |
input | str | required | The prompt sent to the agent each time the trigger fires. |
run_at | str | None | ISO timestamp for a single run. |
every | str | None | Repeat unit: "minute", "hour", "day", "week" or "month". |
interval | int | 1 | Step for minute and hour schedules, for example every 2 hours. |
at | str | None | Time of day as "HH:MM" for day, week and month schedules. |
on | list | None | Weekday names for week, day-of-month numbers for month. |
timezone | str | "UTC" | IANA time zone for the schedule. |
event | TriggerOption | None | An event from a connected tool's triggers. |
notifications | bool | False | Send a notification each time the trigger fires. |
enabled | bool | True | Whether the trigger is active. |
| Method | What it does |
|---|---|
aix.Trigger(...).save() | Create or update a trigger. |
aix.Trigger.get(id) | Retrieve one trigger. |
aix.Trigger.search(agent=...) | List an agent's triggers as a page. |
trigger.delete() | Remove a trigger. |
Next steps
- Deployment: call your agent from production code.
- Sessions and memory: keep context across runs.
- API reference: trigger: every parameter and method.