# Keep notes in sync

> Send meeting notes to another app (a company wiki, a context engine) as you save them, with a small receiver that checks Waddle's signature.

## 1. A receiver

Any https endpoint that takes a POST will do. This one, in Node, checks the signature and keeps each note by its path. To try it on this Mac, use `http://localhost:8787` as the address (Waddle allows http only to this Mac). Save it as `server.mjs`, with the function from the Webhooks page as `from-waddle.mjs`:

```js
import { createServer } from 'node:http';
import { fromWaddle } from './from-waddle.mjs'; // the function on the Webhooks page

const SECRET = process.env.WADDLE_SECRET; // the whsec_… from Waddle's Preferences
const save = (path, markdown) => { /* your store */ }, move = (from, to) => {}, remove = (path) => {};

createServer((req, res) => {
  let body = '';
  req.setEncoding('utf8'); // a character split across chunks would break the signature
  req.on('data', (c) => (body += c));
  req.on('end', () => {
    if (!fromWaddle(SECRET, req.headers, body)) return res.writeHead(401).end();
    const { type, data } = JSON.parse(body);
    if (type === 'note.saved' || type === 'meeting.noted' || type === 'meeting.summarised') save(data.note.path, data.note.markdown);
    if (type === 'note.moved') move(data.from, data.note.path);
    if (type === 'note.trashed') remove(data.note.path);
    res.writeHead(204).end();
  });
}).listen(8787);
```

Answer 2xx quickly. A 5xx or a timeout makes Waddle try again later; any other 4xx makes it stop and tell you.

## 2. The webhook

In Waddle's Preferences → Webhooks, add one with your receiver's address and pick the notes: say, meetings from your Work calendar. Leave "Send the notes already there" off unless you want the backlog too. Press **Send a test** and check your receiver got a `waddle.test`.

## 3. Sensitive notes

Turn on **Ask me first**. Each send waits at the top of Preferences → Webhooks for your yes, and you can see the exact body before it goes.

Every type, header and retry rule: [Webhooks](https://docs.waddle.sh/webhooks.md).
