Quick overview
This workflow receives Lection scheduled-scrape webhook events and writes the returned dataset records into Google Sheets, deduplicating by a chosen unique column using an upsert operation.
How it works
- Receives a POST webhook from Lection for a scheduled scrape delivery.
- Verifies the request by comparing the
x-lection-secret header against a configured shared secret and returns 401 if it does not match.
- Checks that the event is
scheduled_scrape.completed and that the dataset contains at least one row, otherwise returns a JSON response indicating nothing was written.
- Splits the incoming
body.dataset.records array into individual items.
- Upserts each record into Google Sheets using “append or update” based on the configured matching (unique) column.
- Aggregates the write results and responds to Lection with a JSON payload including how many rows were written.
Setup
- Create a Google Sheet with a header row whose column names exactly match the field names in Lection’s
dataset.records.
- Add a Google Sheets OAuth2 credential in n8n and set the target Spreadsheet ID and sheet name in the Google Sheets node.
- Set the matching (unique) column used for deduplication in the Google Sheets node’s matching columns setting.
- Configure the expected webhook secret in the workflow (or remove the secret check) and set the same secret in Lection’s webhook delivery settings.
- Copy the workflow’s production webhook URL and configure it as the Webhook delivery channel for your Lection scheduled scrape, ensuring the webhook path matches your setup.
Requirements
- A Lection account on a paid plan (webhook delivery is paid-only), with a scheduled scrape that has a stable unique column
Additional info
Activate the workflow and use its production webhook URL, not the test URL. Test sends from Lection are acknowledged but never written, so use Run now in Lection to check the mapping. Sheet column names are case-sensitive. If you pick the n8n destination in Lection, which has no secret field, delete the Secret matches? node.