Prototypes Prototype docsP11 · Docs and assistant
Connections (P22)
DocsPage 23 of 30

Connections (P22)

Switchboard connects the tools a business uses. Four tools send webhooks: a shop, a payment service, a code host and a form tool. Switchboard delivers each event to the tools that need it and tries again when a delivery fails.

Checking a sender

Each source has an address outside the portfolio's login, because a tool cannot type a password, and a secret. The server checks each signature with that secret, in the scheme the tool uses: Shopify's HMAC-SHA256 of the body in base64, Stripe's time and HMAC-SHA256 in hex with 5 minutes of tolerance, GitHub's HMAC-SHA256 in hex after sha256=, and the Standard Webhooks scheme over the id, the time and the body. A wrong or old signature is refused with 401 and listed on the server page.

An event is stored once by the id its sender gave it. The same event sent again is answered with 200 and changes nothing, since senders try again when an answer is lost.

Delivering

The server answers the sender at once and delivers from a Durable Object alarm. Each destination the route names gets its own delivery with its own idempotency key. A delivery succeeds on an answer in the 200s within 3 seconds. Otherwise it is tried again after 2, 4, 8, 16 and 32 seconds, each pause a fifth longer or shorter at random. After 6 tries it waits among the failed deliveries, where a person sends it again with 6 more tries. The Deliveries page shows every try: the answer, how long it took and when the next try is.

The destinations

Accounting, Warehouse, Team chat and CRM are simulated inside the server, so a person can switch each one off, slow it down or make it fail twice. A destination applies a delivery once per idempotency key. A slow destination applies a delivery but answers after the sender stopped waiting, and the next try is answered without applying it twice.

Your endpoint takes a real https address. It then gets a copy of every event, signed with the Standard Webhooks scheme, so it can check that Switchboard sent it.

Previous: Course player (P21). Next: Admin from a spreadsheet (P19).

How Prototype docs is built

The pages are written in Markdown and built into these pages and an index of 154 sections. The assistant answers from the index, and every answer names the sections it was taken from.