Pass a variable from pageFunction() via Webhooks JSON
Pass a variable from pageFunction() via Webhooks JSON
At a glance
The community member is trying to pass a variable from a pageFunction to a webhook, but is unable to get the value. They have tried using {{resource.numberOfTests}} and {{numberOfTests}} in the webhook integration JSON, but one returns a validation error and the other doesn't have access to the data.
In the comments, another community member explains that the webhooks don't have access to the data, and the data needs to be loaded in the code called by the webhook. The community member asks for basic examples on how to do this.
Another community member suggests two options: create a new webhook in the interface and then pull the results with another API call, or attach a dynamic webhook at the end of the run and add the results there directly.
Im trying to pass a returned variable from pageFunctions via webhooks, but I cannot get the value. My code: async function pageFunction(context) { await context.skipLinks(); const $ = context.jQuery; const pageTitle = $('title').first().text(); const matches = pageTitle.match(/((\d+))/); const numberOfTests = 0;
if (matches !== null) { numberOfTests = parseInt(matches[1]); } context.log.info(${numberOfTests})
Im just trying to scrape a website behind a login (that I've managed to acheive) to see if there is something available, and pass this boolean variable via a webhook to my Home Assistant