Implementation:Langfuse Langfuse Webhook Automation Repository
| Knowledge Sources | |
|---|---|
| Domains | Automations, Webhooks, Data Access |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
Repository layer for CRUD operations on Langfuse automations, triggers, and actions, providing domain-typed access to automation configurations stored in PostgreSQL via Prisma.
Description
This module serves as the data access layer for the Langfuse automation system, which connects triggers (events that fire) to actions (operations to perform, such as webhook calls or Slack notifications). It queries PostgreSQL through Prisma and converts raw database records into strongly-typed domain objects.
Key responsibilities:
- Action retrieval --
getActionByIdreturns safe (secret-stripped) action configurations, whilegetActionByIdWithSecretsdecrypts secret webhook headers for execution contexts. - Trigger configuration --
getTriggerConfigurationsfetches triggers by event source and status, including their linked action IDs, for event processing pipelines. - Automation CRUD --
getAutomationByIdandgetAutomationsreturn full automation domain objects (trigger + action pairs) with proper type conversions. - Failure tracking --
getConsecutiveAutomationFailurescounts sequential ERROR executions for circuit-breaker logic, respecting thelastFailingExecutionIdreset point. - Domain conversion -- Internal helpers convert Prisma models to domain types, handling webhook header decryption/display, legacy header format migration, and safe config stripping.
The module exports the TriggerDomainWithActions type that extends trigger domain objects with their associated action IDs.
Usage
Use this repository when processing automation events (e.g., trace completion triggers), when displaying automation configurations in the UI, or when executing webhook/Slack actions. The "with secrets" variant should only be used in execution contexts where actual header values are needed.
Code Reference
Source Location
- Repository: Langfuse
- File: packages/shared/src/server/repositories/automation-repository.ts
- Lines: 1-311
Signature
export type TriggerDomainWithActions = TriggerDomain & { actionIds: string[] };
export const getActionByIdWithSecrets = async (params: {
projectId: string;
actionId: string;
}): Promise<ActionDomainWithSecrets | null>;
export const getActionById = async (params: {
projectId: string;
actionId: string;
}): Promise<ActionDomain | null>;
export const getTriggerConfigurations = async (params: {
projectId: string;
eventSource: TriggerEventSource;
status: JobConfigState;
}): Promise<TriggerDomainWithActions[]>;
export const getAutomationById = async (params: {
projectId: string;
automationId: string;
}): Promise<AutomationDomain | null>;
export const getAutomations = async (params: {
projectId: string;
triggerId?: string;
actionId?: string;
}): Promise<AutomationDomain[]>;
export const getConsecutiveAutomationFailures = async (params: {
automationId: string;
projectId: string;
}): Promise<number>;
Import
import {
getActionById,
getActionByIdWithSecrets,
getTriggerConfigurations,
getAutomationById,
getAutomations,
getConsecutiveAutomationFailures,
} from "@langfuse/shared/src/server/repositories/automation-repository";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| projectId | string | Yes | Project scope for all queries |
| actionId | string | Yes (for action queries) | ID of the action to retrieve |
| automationId | string | Yes (for automation queries) | ID of the automation to retrieve |
| eventSource | TriggerEventSource | Yes (for triggers) | Event source type (e.g., trace-created) |
| status | JobConfigState | Yes (for triggers) | Trigger status filter (e.g., ACTIVE) |
| triggerId | string | No | Optional filter by trigger ID |
Outputs
| Name | Type | Description |
|---|---|---|
| ActionDomain | null | Action with safe (redacted) webhook config |
| ActionDomainWithSecrets | null | Action with decrypted secret headers for execution |
| TriggerDomainWithActions[] | Array | Triggers with their linked action IDs |
| AutomationDomain | null | Full automation with trigger and action domain objects |
| consecutiveFailures | number | Count of sequential ERROR executions since last success |
Usage Examples
import {
getTriggerConfigurations,
getActionByIdWithSecrets,
getConsecutiveAutomationFailures,
} from "@langfuse/shared/src/server/repositories/automation-repository";
// Fetch active triggers for trace completion events
const triggers = await getTriggerConfigurations({
projectId: "proj_123",
eventSource: "trace-created",
status: "ACTIVE",
});
// Get action with decrypted headers for webhook execution
const action = await getActionByIdWithSecrets({
projectId: "proj_123",
actionId: triggers[0].actionIds[0],
});
// Check consecutive failures for circuit breaker
const failures = await getConsecutiveAutomationFailures({
automationId: "auto_456",
projectId: "proj_123",
});