69f7f3b206e29ba5af18916fdd2565f45ef5ea67
All checks were successful
Lint and Syntax Check / build (pull_request) Successful in 5s
Assign Me Openclaw (
)
This project is a serverless function (designed for SHSF) that handles Gitea webhooks for issue and pull request assignments. It notifies an AI agent (via OpenClaw) when they are assigned or unassigned, even if the unassignment event lacks assignee data. The function uses a database to track assignees across events, ensuring accurate notifications.
Features
- Multiple Assignee Support: Correctly handles Gitea events with multiple assignees.
- State Persistence: Uses a database to track assignees across events, ensuring "unassigned" events have the necessary context even when the payload is sparse.
- AI Integration: Sends formatted Markdown notifications to an OpenClaw-compatible API.
- Assignment Logic: Specifically identifies when the configured
AGENT_USERNAMEis involved in an assignment change.
Environment Variables
The following environment variables are required for the service to function:
| Variable | Description |
|---|---|
OPENCLAW_URL |
The endpoint URL for the OpenClaw API. (with hook path) |
OPENCLAW_TOKEN |
The authentication token for OpenClaw. (from hooks, not gateway ui) |
OPENCLAW_PROXY_AUTH |
(Optional) Proxy credentials in username:password format. |
DATABASE_STORAGE_NAME |
The name of the database storage to use. |
AGENT_USERNAME |
The Gitea username of the AI agent (e.g., whateveryouragentisnamed). |
How it works
- Webhook Reception: The
main(args)function receives a POST request from Gitea. - Event Filtering: It filters for
issuesandpull_requestevents withassignedorunassignedactions. - Database Lookups: If an
unassignedevent lacks assignee data, the script retrieves the last known assignees from the database. - Agent Notification: If the configured
AGENT_USERNAMEis found in the assignee list, a detailed Markdown message is constructed and sent to OpenClaw. - Database Sync: The current state of assignees for the specific issue/PR is updated in the database for future reference.
Development
The project consists of:
main.py: The entry point and logic for the webhook handler._db_com.py: (Internal dependency at SHSF Runner level) Database communication module.requirements.txt: Python dependencies.
Usage in SHSF
This script is intended to be deployed as a serverless function using SHSF. Ensure that all required environment variables are set in your Function.
Description
Languages
Python
100%