Creating triggers
Create a trigger to start receiving events. A trigger watches for a specific event (e.g., GITHUB_COMMIT_EVENT) on a specific user's connected account.
Prerequisites
Before creating triggers, ensure you have:
- An auth config for the toolkit you want to monitor
- A connected account for the user whose events you want to capture
You can create triggers using the SDK or the Devcaster dashboard.
Using the SDK
Before creating a trigger, inspect the trigger type to see what configuration it requires. Then create the trigger with the required config.
When you pass a user_id, the SDK automatically finds the user's connected account for the relevant toolkit. If the user has multiple connected accounts for the same toolkit, it uses the most recently created one. You can also pass a connected_account_id/connectedAccountId directly if you need more control.
from devcaster import Devcaster
devcaster = Devcaster()
user_id = "user-id-123435"
# Check what configuration is required
trigger_type = devcaster.triggers.get_type("GITHUB_COMMIT_EVENT")
print(trigger_type.config)
# Returns: {"properties": {"owner": {...}, "repo": {...}}, "required": ["owner", "repo"]}
# Create trigger with the required config
trigger = devcaster.triggers.create(
slug="GITHUB_COMMIT_EVENT",
user_id=user_id,
trigger_config={"owner": "your-repo-owner", "repo": "your-repo-name"},
)
print(f"Trigger created: {trigger.trigger_id}")import { Devcaster } from '@devcaster/core';
const devcaster = new Devcaster();
const userId = 'user-id-123435';
// Check what configuration is required
const triggerType = await devcaster.triggers.getType("GITHUB_COMMIT_EVENT");
console.log(triggerType.config);
// Returns: {"properties": {"owner": {...}, "repo": {...}}, "required": ["owner", "repo"]}
// Create trigger with the required config
const trigger = await devcaster.triggers.create(
userId,
'GITHUB_COMMIT_EVENT',
{
triggerConfig: {
owner: 'your-repo-owner',
repo: 'your-repo-name'
}
}
);
console.log(`Trigger created: ${trigger.triggerId}`);The trigger instance uses the toolkit version configured during Devcaster initialization (defaults to 'latest'). See Toolkit Versioning for details.
Using the dashboard
- Navigate to Auth Configs and select the auth config for the relevant toolkit
- Navigate to Active Triggers and click Create Trigger
- Select the connected account for which you want to create a trigger
- Choose a trigger type and fill in the required configuration
- Click Create Trigger