To add a new trigger, you must implement a webhook endpoint and a processing function to start the agent run.
- Add a webhook endpoint in
agent/webapp.py to receive and parse the payload. - Create a processing function that uses a
langgraph_client to create a run with the necessary config.configurable fields.
Required config.configurable fields:
repo: {"owner": "...", "name": "..."} — The target GitHub repo.source: A string identifying the trigger (used for auth and communication).user_email: The triggering user's email (used for GitHub OAuth resolution).
Example Implementation:
# 1. Webhook endpoint in agent/webapp.py
@app.post("/webhooks/my-trigger")
async def my_trigger_webhook(request: Request, background_tasks: BackgroundTasks):
payload = await request.json()
task_description = payload["description"]
repo_config = {"owner": "my-org", "name": "my-repo"}
background_tasks.add_task(process_my_trigger, task_description, repo_config)
return {"status": "accepted"}
# 2. Processing function
async def process_my_trigger(task_description: str, repo_config: dict):
thread_id = generate_deterministic_id(task_description)
langgraph_client = get_client(url=LANGGRAPH_URL)
await langgraph_client.runs.create(
thread_id,
"agent",
input={"messages": [{"role": "user", "content": task_description}]},
config={"configurable": {
"repo": repo_config,
"source": "my-trigger",
"user_email": "user@example.com",
}},
if_not_exists="create",
)
# 1. Webhook endpoint in agent/webapp.py
@app.post("/webhooks/my-trigger")
async def my_trigger_webhook(request: Request, background_tasks: BackgroundTasks):
payload = await request.json()
task_description = payload["description"]
repo_config = {"owner": "my-org", "name": "my-repo"}
background_tasks.add_task(process_my_trigger, task_description, repo_config)
return {"status": "accepted"}
# 2. Processing function
async def process_my_trigger(task_description: str, repo_config: dict):
thread_id = generate_deterministic_id(task_description)
langgraph_client = get_client(url=LANGGRAPH_URL)
await langgraph_client.runs.create(
thread_id,
"agent",
input={"messages": [{"role": "user", "content": task_description}]},
config={"configurable": {
"repo": repo_config,
"source": "my-trigger",
"user_email": "user@example.com",
}},
if_not_exists="create",
)