Outcome
Each booking event that you choose gets to your flow in some seconds. The events are booked, moved, cancelled and the others. An event gets to the flow only after a check of its signature. So nothing else can start the flow when it posts to it. A usual flow adds or updates the person as a contact in Dynamics 365, in Dataverse, with the time of the meeting.
There is no Dynamics app for bookameet.ing. The webhooks of bookameet.ing send the bookings, and they follow the open Standard Webhooks specification.
What you need
A webhook, Power Automate and a small function that checks signatures.
- Power Automate with the "When an HTTP request is received" trigger. This is a premium connector.
- A place to run some lines of JavaScript on an https address, for example an Azure Function on Node 20 or later. Power Automate cannot check a signature itself. So this small function checks it, and sends on only the real deliveries.
An API key from Assistants and apps for steps 3, 4 and 6, with these boxes ticked. You can also do these steps on the dashboard, under Integrations → Webhooks.
- The line that starts "send your booking data to new places", for step 3 and for a new secret. It is not ticked unless you tick it.
- The line that starts "send your booking data to your webhooks again, or as a test", for steps 4 and 6. It is not ticked unless you tick it.
The recipe needs nothing more, so you can untick the other boxes.
Steps
- In Power Automate, make a flow that starts with When an HTTP request is received. Save it, and copy its URL.
- Put the two files below in an Azure Function app, as a function with an HTTP trigger. Set the URL of the flow as the setting
FLOW_URL. Copy the https address of the function. route:POST /api/v1/me/webhooksadds a webhook to the address of the function, with the events that you want. You can also add it on the dashboard, under Integrations → Webhooks. It shows the signing secret one time. Put the secret in the settings of the function, asWEBHOOK_SECRET.route:POST /api/v1/me/webhooks/{id}/testsends a test notice, aping. The function checks it and sends it to the flow. The run shows in the history of the flow.- In the flow, add Parse JSON on the body, and then a condition on
type. Forbooking.created, add the Dataverse action Add a new row in Contacts, or update a row. Use the name and email of the person that the booking is for, fromdata.invitee. - If something does not arrive,
route:GET /api/v1/me/webhooks/{id}/deliveriesshows each notice that we sent and the answer of the function.
Flow
This is step 3 with your key, not on the dashboard, for the events that you want. The secret of the answer is WEBHOOK_SECRET:
curl -X POST "https://bookameet.ing/api/v1/me/webhooks" \
-H "Authorization: Bearer $API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url":"https://<your-function-app>.azurewebsites.net/api/bookings","events":["booking.created","booking.rescheduled","booking.cancelled"]}'This is the check, as a module that you can use where Node runs. It follows the steps in the documentation of the API. It uses the raw body and a 5-minute window on the timestamp. It uses HMAC-SHA256 with the bytes of the secret, and a constant-time comparison.
// verify-webhook.mjs
import { createHmac, timingSafeEqual } from 'node:crypto';
/**
* True when a delivery is really from your webhook: signed with its secret (whsec_…), and sent within 5 minutes.
* `headers` are the request's, with lower-case names; `body` is the raw body as received, before any JSON parsing.
*/
export function verifyWebhook(secret, headers, body, nowSeconds = Math.floor(Date.now() / 1000)) {
const id = headers['webhook-id'];
const timestamp = headers['webhook-timestamp'];
const signatures = headers['webhook-signature'];
if (!id || !timestamp || !signatures || !secret.startsWith('whsec_')) return false;
if (!/^\d+$/.test(timestamp) || Math.abs(nowSeconds - Number(timestamp)) > 5 * 60) return false;
const key = Buffer.from(secret.slice('whsec_'.length), 'base64');
const expected = createHmac('sha256', key).update(`${id}.${timestamp}.${body}`).digest();
return signatures.split(' ').some((entry) => {
const [version, signature] = entry.split(',');
if (version !== 'v1' || !signature) return false;
const given = Buffer.from(signature, 'base64');
return given.length === expected.length && timingSafeEqual(given, expected);
});
}This is the Azure Function that uses it. It sends each real delivery on to the flow:
// index.mjs
import { app } from '@azure/functions';
import { verifyWebhook } from './verify-webhook.mjs';
app.http('bookings', {
methods: ['POST'],
authLevel: 'anonymous',
handler: async (request) => {
const body = await request.text();
const headers = Object.fromEntries(request.headers);
if (!verifyWebhook(process.env.WEBHOOK_SECRET, headers, body)) return { status: 401 };
const flow = await fetch(process.env.FLOW_URL, { method: 'POST', headers: { 'content-type': 'application/json', 'webhook-id': headers['webhook-id'] }, body });
return { status: flow.ok ? 204 : 502 };
},
});This is the Parse JSON schema for step 5 of the flow. It has enough for the person that the booking is for, and for the time:
{
"type": "object",
"properties": {
"type": { "type": "string" },
"timestamp": { "type": "integer" },
"data": {
"type": "object",
"properties": {
"id": { "type": "string" },
"status": { "type": "string" },
"start": { "type": "integer" },
"end": { "type": "integer" },
"eventTitle": { "type": "string" },
"invitee": {
"type": "object",
"properties": { "name": { "type": "string" }, "email": { "type": "string" } }
}
}
}
}
}Notes
- The times of a delivery are epoch milliseconds (
data.start), as we post them. In the flow,addSeconds('1970-01-01T00:00:00Z', div(<start>, 1000))changes one into a date. - A delivery can come more than one time, and in a different order. Use
webhook-idto skip a delivery that came before. The function sends it on to the flow as a header. Usedata.statusto know the state of a booking. - Answer in 10 seconds or less. The trigger of the flow answers immediately, so the function answers immediately too. We try a failed delivery again for about one and a half days.
- If you lost the secret,
route:POST /api/v1/me/webhooks/{id}/rotate-secretmakes a new one. Put the new one inWEBHOOK_SECRET.