|
Download integrations/n8n/README.md from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 3.47 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/integrations/n8n/README.md
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/integrations/n8n/README.md
-
curl -L -o README.md https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/integrations/n8n/README.md
3.47 kB
| # Patchwise → Telegram (n8n) | |
| `patchwise-telegram.json` is an n8n workflow that receives Patchwise's notifications and posts them to a Telegram chat. Each message has an **Open in Patchwise** button. Nothing is approved from the chat: the button opens the screen where you confirm. | |
| ``` | |
| Patchwise ── signed POST ──▶ n8n webhook ──▶ check signature ──▶ Telegram message | |
| ``` | |
| ## What Patchwise sends | |
| Patchwise sends a `POST` with a JSON body: | |
| ```json | |
| { | |
| "id": 42, | |
| "kind": "run.waiting_approval", | |
| "title": "79 scenarios are ready for your approval", | |
| "body": "Procure-to-Pay test run on Local mock pod", | |
| "coworker": "Test generator", | |
| "run_id": "...", | |
| "link": "https://your-patchwise/runs/...", | |
| "created_at": "..." | |
| } | |
| ``` | |
| It also sends these headers: | |
| | Header | Content | | |
| |---|---| | |
| | `X-Patchwise-Event` | The kind of event | | |
| | `X-Patchwise-Delivery` | The event id | | |
| | `X-Patchwise-Signature` | `sha256=<HMAC-SHA256 of the raw body with FPT_NOTIFY_SECRET>` | | |
| Kinds: | |
| | Kind | Meaning | | |
| |---|---| | |
| | `run.waiting_approval` | Scenarios are waiting for your approval | | |
| | `run.waiting_decision` | A failure is waiting for your decision | | |
| | `run.finished` | A test run finished | | |
| | `run.failed` | A test run failed | | |
| | `run.stopped` | A test run was stopped | | |
| | `defect.created` | A defect was confirmed | | |
| | `test` | The test message from Settings | | |
| ## Set up | |
| 1. **Create a Telegram bot and find your chat id.** | |
| - In Telegram, talk to **@BotFather**, send `/newbot` and copy the token. | |
| - Send your bot one message, then open `https://api.telegram.org/bot<TOKEN>/getUpdates`. The number at `chat.id` is your chat id. | |
| - Group chats have negative ids. | |
| 2. **Import the workflow.** | |
| - In n8n, choose **Workflows → Import from file** and pick `patchwise-telegram.json`. | |
| - Open **Send to Telegram**, create a **Telegram** credential with the bot token and select it. | |
| 3. **Give the workflow the secret and the chat id.** Use either option: | |
| - **Environment:** set `PATCHWISE_SECRET` and `TELEGRAM_CHAT_ID` on the n8n server. | |
| - **In the workflow:** paste them into `SECRET_FALLBACK` and `CHAT_ID_FALLBACK` at the top of **Check signature and write message**. | |
| Use the in-workflow option when the n8n server blocks environment access in nodes (`N8N_BLOCK_ENV_ACCESS_IN_NODE=true`), as the Patchwise n8n Space does. | |
| 4. **Allow the crypto module.** The signature check uses Node's built-in `crypto`, so set `NODE_FUNCTION_ALLOW_BUILTIN=crypto` on the n8n server. | |
| 5. **Activate the workflow** and copy its **Production URL**. It ends in `/webhook/patchwise-events`. | |
| 6. **Point Patchwise at the workflow.** On the Patchwise server, set these and restart: | |
| - `FPT_NOTIFY_WEBHOOK_URL`: the Production URL. | |
| - `FPT_NOTIFY_SECRET`: the same secret as in step 3. | |
| The n8n host must also be allowed by Patchwise's outbound-traffic list. | |
| 7. **Test it.** In Patchwise, open **Settings → Notifications** and press **Send a test message**. | |
| ## Notes | |
| - **Invalid messages:** a message with a missing or wrong signature is dropped without a reply. | |
| - **The secret:** use a long random value, for example `python -c "import secrets; print(secrets.token_hex(32))"`, and keep it out of code and chats. | |
| - **Adding more channels:** add nodes after **Check signature and write message**, for example Slack, Teams or e-mail. Patchwise itself does not change. | |