Core Concepts

Bi-Directional Triggers

Connect active webhooks and propagate external system events directly back into your AI agent loops.

AI agents shouldn't simply execute tasks when prompted; they should actively monitor environments and react to events. Datafuse's Bi-Directional Triggers enable your agents to listen to real-world triggers, such as incoming Slack messages, new GitHub pull requests, or database updates, and respond instantly.


Architecture of Event-Driven Agents

Datafuse manages the entire webhook ingress, event parsing, and routing pipeline, acting as a broker that translates platform-specific payloads into normalized agent events:

Compiling diagram schema...

1. Subscribing to Webhooks

Each compiled provider toolkit can define event triggers within its integration YAML. When a user connects their account, Datafuse automatically registers a webhook URL with the third-party application on behalf of that user.

Defining Triggers in YAML

Here is how triggers are registered inside a connector's YAML configuration:

triggers:
  - slug: new_github_issue
    title: New Issue Created
    description: Fires whenever a new issue is opened inside a repository.
    event_type: github.issue.opened
    input_schema:
      type: object
      properties:
        repository:
          type: string
          description: The repository name.

2. Webhook Security and Verification

Datafuse secures trigger endpoints to protect your agent infrastructure from malicious webhook spoofing:

  • Signature Authentication: Datafuse automatically verifies cryptographic headers (such as GitHub's X-Hub-Signature-256 or Slack's signature verification) before routing the event.
  • Decoupled Secret Ingress: Signing secrets are kept in the credentials vault and matched dynamically at the gateway boundary.
  • IP Whitelisting: Connections from outside recognized third-party IP clusters are blocked at the perimeter.

3. Propagating Events to your Agent Loop

Once triggers are activated, you can listen to event streams directly inside your agent loop using our WebSocket SDK connections or HTTP webhook handlers.

Here is how you set up a dynamic event handler in Python:

import os
from datafuse import Datafuse

# Initialize client
sdk = Datafuse(api_key=os.getenv("DATAFUSE_API_KEY"))

# Register callback handler for active events
def handle_incoming_event(event):
    print(f"🔥 Trigger Event Received: {event.event_type}")
    print(f"Payload: {event.payload}")

    # Pass event payload to your LLM or framework
    # my_agent.process_context(event.payload)

# Listen to incoming event streams from Datafuse Webhook Broker
sdk.triggers.subscribe(
    trigger_slug="github.new_issue",
    callback=handle_incoming_event
)

!TIP Triggers are highly optimized for agent state machines. By binding webhook events directly to agent loop initiators, you can build autonomous self-healing workflows (e.g. automatically replying to a GitHub issue when it is opened).