LangGraph + FetchHook: Triggering Stateful Agent Workflows from Webhooks
LangGraph is designed for complex, cyclic agent state machines. FetchHook provides the reliable event ingress needed to trigger these graphs from external services like Stripe or GitHub without a public server.
The Graph Trigger Primitive
import requests
from langgraph.graph import StateGraph
# 1. Pull events from FetchHook
def check_for_triggers():
res = requests.get("https://api.fetchhook.app/api/v1/stash_123",
headers={"Authorization": "Bearer fh_xxx"})
return res.json().get('events', [])
# 2. Feed event data into the Graph state
events = check_for_triggers()
for event in events:
app.invoke({"input": event['payload'], "source": event['provider']})#How do I trigger a LangGraph from a webhook?
LangGraph applications usually wait for user input. By using FetchHook as an asynchronous mailbox, you can turn your graph into a 'Reactive Agent.' Instead of the graph sitting idle, a simple cron job or polling loop 'pulls' webhooks from FetchHook and executes `graph.invoke()` for every new event received.
#Stateful Event Handling
Because LangGraph manages state, you can map webhook payloads directly to your state schema. For example, a 'GitHub Issue' webhook can initialize a 'Coding Agent' graph, while a 'Stripe Payment' webhook can trigger a 'Fulfillment' node within the same architecture.
Agent Protocol Instruction