Assign Me Openclaw (Works with SHSF)

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_USERNAME is 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).
AGENT_PROMPT_FILE (Optional) Path to a custom Markdown template for notifications. If not provided, a default template will be used.

How it works

  1. Webhook Reception: The main(args) function receives a POST request from Gitea.
  2. Event Filtering: It filters for issues and pull_request events with assigned or unassigned actions.
  3. Database Lookups: If an unassigned event lacks assignee data, the script retrieves the last known assignees from the database.
  4. Agent Notification: If the configured AGENT_USERNAME is found in the assignee list, a detailed Markdown message is constructed and sent to OpenClaw.
  5. Database Sync: The current state of assignees for the specific issue/PR is updated in the database for future reference.

Webhook Pointers

Ensure you Webhook is pointed from YOUR and YOUR AGENTS Gitea account to the Function, or have an Gitea Wide Webhook pointed to your Function, the code will filter events that don't belong to your agent.

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
Assign your agent and have it get instant notifications via SHSF and Gitea Webhooks
Readme 104 KiB
Languages
Python 100%