Setting up a Webhook trigger (for Formspark.io)
Need a generic way to kick off playbook runs in Relay? With a webhook trigger you can do just that. Learn how to set one up in a few minutes, via an example integration with Formspark.io
Setting it up
In this guide, you'll learn how to set up a webhook trigger in Relay. Specifically, we'll set up a webhook trigger for Formspark.io, an embeddable service.
The instructions in this guide are not just relevant for Formspark, though. They'll help you set up any webhook-based trigger in Relay. Very helpful when you want to integrate Relay with products that (let us know, though!)
If you don't have a Relay account yet, head over to relay.app/signup to create one for free!
1. Add a webhook trigger
First, add a webhook trigger by clicking 'Add trigger' and then 'Incoming webhook'
2. Copy the webhook URL
Next, we're going to prepare the setup of the Formspark form. You'll want to copy the unique URL that will trigger this playbook. You can find that URL in the Usage section in the side panel.
Every webhook trigger requires a secret token (secretToken) to be sent as part of the request. It is recommended to send this token as part of the JSON body in the POST request. However, it's also possible to provide it as a URL parameter.
Note: it is important to keep this token secret. Everybody with this token and the URL of the playbook will be able to trigger runs of your playbook.
For our Formspark integration, we'll put the token in the URL so that it won't leak to anyone that can view a (potentially public) Formspark form. Click the icon to copy the URL.
3. Set up a Formspark form - part 1
In the Formspark UI, we'll create a new form. We'll paste our URL in the Webhook URL field.
4. Set up a Formspark form - part 2
Now it's time to create a form. We're just going to use an example provided by Formspark, which you can find in the How-to tab on top of the page. We'll take the Contact form example, and click Copy to clipboard.
5a. (Recommended) Configure the webhook trigger via a test HTTP request
For an alternative (manual) way of configuring a webhook trigger, go to step 5b
The easiest way to set up the Webhook trigger in Relay, is by sending a test request. Relay will automatically infer all the parameters that came with the webhook, and populate them in the webhook configuration. This is by far the recommended way of setting up a webhook trigger.
Note: you can only use this approach if you haven't added any parameters manually (see step 5b) and the playbook is (still) turned Off.
To send a test request, we'll paste the HTML of the example Contact form on CodePen.io, and we'll submit it with some test values. Of course is just one of the many ways how you can submit the example form.
You'll notice back in Relay that the parameters of the webhook have been filled in automagically!
5b. (Alternative) Configure the webhook trigger manually
If sending a test request to the webhook trigger (step 5a) is not possible, you can enter parameters manually.
Make sure to pay attention to the data type and name of each parameter. They should exactly match what you're sending over.
6. Add the Slack automation
Now that the trigger is set up, let's add a Slack automation that sends the form response to a channel.
Reference data fields from the webhook trigger by clicking the Insert menu using the @-key keyboard shortcut.
7. Turn on the playbook
Almost done! Now turn on the playbook so that it will start accepting webhook requests
8. Test the playbook!
And finally, let's test our playbook. We'll just submit the same form again in Codepen, and when you go back to Relay you'll notice in the Runs tab that a run has been kicked off and the Slack message has been sent.
That's it! Now that you have your Webhook trigger up and running, explore some of the powerful features in Relay like AI Autofill.