Inside your listener function, you can respond to any Event that occurs in the environment you’re listening to.
Your transformation and validation code is already responding to Record level Events, but a listener can respond to any Event, like the Action triggered by a button click.
Adding behavior to the action
In this step of the tutorial, we’re going to configure our Workbook’s primary Action, defined in our Blueprint as the
The primary Action button is located in the upper right corner of your Workbook.
When this button is clicked by a user, a Job is created. We’re going to listen for that
and call out to a waiting webhook to export our data.
To configure our listener to call to a webhook, let’s create a webhook. We recommend using Webhook.site. Simply navigate to their site and copy
Your unique URL.
Now, update the value of the
WEBHOOK_SITE_URL variable in your
.env file with the webhook url you just copied.
Watch your Action
Check your listener is still running. If not, run
npx flatfile@latest develop.
Now, in your Workbook and click the “Submit” button in the top right corner.
Over on your Webhook.site browser tab look at the query log and observe that the webhook received a call; this is the Action running.
Congratulations! You now now have an example listener that is performing transformations and validations in response to changes in your Workbook, and you’ve set up an action to export your cleaned data.
You’ve been running this listener locally while in development. Next, let’s see how easy it is to Deploy to Flatfile.