Unit introduction
Welcome to the fourth and final unit in the “Introduction to HTTP” course, which is a part of the Make Intermediate.
By now you should know what HTTP is, what it can do and how to use HTTP GET and POST requests in Make.
In this unit you will explore the connection of HTTP to a webhook, how can HTTP work with a webhook and what would be the benefits of using the two together.
Let’s dive into it, shall we?
A brief overview of webhooks
At this point we will not go into too much depth about webhooks, as we will be covering webhooks in detail in the next course which is completely dedicated to that topic. For now, you just need to know the basics about webhooks.
What are webhooks?
Webhooks are a method of receiving notifications that an event has happened from another application or scenario, as soon as it happens.
Webhooks allow you to send data to Make over HTTP by creating a hyperlink (URL). You can call this link from an external app, or from another Make scenario.
Webhooks are a great way to connect different apps to Make, or to connect different scenarios inside Make. That way you get data instantly when something happens on the other platform or in another Make scenario.
A quick example
You can think of a webhook as a letter box.
The webhook URL is like the address of the letter box. Other systems can put messages in there for you. You can then do whatever you want with these messages. For example, you could use them in a Make scenario.
Usually, with other Make modules, you can only initiate a call/message to another system.
Using the letter box (webhook), you can inverse the direction and other systems can send messages to you.
How do they work?
Webhooks usually act as instant triggers. This means you’d use them in the beginning of a scenario to trigger the execution of the scenario.
You can visually recognize this by the lightning scheduling icon or the INSTANT tag on the module.
Webhooks vs HTTP
HTTP works as a request-response protocol between a client and server.
Webhooks work by receiving notifications from one application to another.
In Make, you can think of a webhook as the opposite of the HTTP module.
You can use the HTTP module to make requests, while a webhook receives requests, instead of making them.
What triggers a webhook?
If a webhook triggers a scenario, what then triggers a webhook?
A webhook can be triggered by an event within Make or by an external event, such as an action or change in another application or another scenario.
For example, you could set up a webhook to be triggered when a form is submitted on your website, or when you get a new order on your e-shop.
For the purpose of the exercise in this unit, we will demonstrate how a webhook can be triggered by an event in Make (a POST request from another scenario). This way, you can test it in Make and you don’t need to use any external web service / app.
Make sure you have done the prep work
In this unit you’ll build a scenario that uses a webhook you have already created in unit 3 of this course.
In order for this scenario to work, you must have the scenario from unit 3 already built (Make Intermediate 3-3 scenario). Otherwise, the scenario you’ll build in this unit won’t be able to run without it.
These two scenarios are interconnected and one is not complete without the other. You can imagine them as linked by a chain or as a set of dominos. If a piece is missing, you cannot go on properly.
If you have not built the Make Intermediate 3-3 scenario yet, please go a step back to unit 3 and build that scenario before proceeding with this exercise.
Once you are ready and have the scenario from unit 3 built, let’s continue!
Have both scenarios open at the same time
You have the Make Intermediate 3-3 scenario prepared, good job!
In this unit, you will be working on two scenarios simultaneously, kind of jumping from one to the other. This might be a bit awkward but in the end you’ll understand why it is like this!
Now open both scenarios in separate tabs/windows in your browser, so you have the tabs of unit 3 and unit 4 scenarios open. If you followed our naming suggestions, these should be the following scenarios:
- Make Intermediate 3-3
- Make Intermediate 3-4
Having them both open at the same time will help you follow the exercise in this unit.
Scenario exercise – building
Now that you have everything prepared, it’s time to start building your scenario! Work through each step before you continue.
Remember Lisa? She runs an online store and wants to offer promotional offers to the customers who are subscribed to her newsletter. Let’s help Lisa to achieve this!
In the previous unit, you encoded data from Google Sheets into a JSON string and then used HTTP POST method to send this data to a webhook. This allowed you to search for users who have subscribed to the newsletter.
In this scenario, you’ll send an email about promo offers to all the users once they have subscribed to the newsletter. You’ll use that same webhook from the HTTP module in unit 3 to trigger this new scenario.
Configure the Webhooks Module
Open the tab with the Make Intermediate 3-4 scenario.
The only module you have here is the previously set up Webhooks > Custom webhook.
Remember, a webhook can only be placed at the beginning of a scenario, as it acts as an instant trigger. The webhook here will receive the data sent through HTTP POST from the Make Intermediate 3-3 scenario.
Open the Webhooks module configuration and click Redetermine data structure. This will automatically determine the data structure of the incoming data. In your case, this is the data you send through that HTTP POST module.
To determine the data structure, you’ll need to send some data first to your webhook.
To do this, navigate to Make Intermediate 3-3 scenario and click Run once there. This will send data to your webhook.
Then, go to Make Intermediate 3-4 scenario. You’ll notice the notification copy changed to Successfully determined.
Click OK to save your module configuration.
Note: This method does not enable data validation. The data structure set up in this way only helps you with mapping the webhook data to subsequent modules in your scenario.
Add and Configure the Email Module
Next, add the Email > Send an Email to a Team Member module. This module will send the email about the promo offer to the customers who have subscribed to the newsletter.
As this is only for testing purposes, you will select your own email. Like this, you will receive the same email the customers will get, so it’s a great way to test if your automation is working as intended.
Let’s configure the Email module.
Under To, select your own email address.
Under Subject, type the subject you wish to reflect in the subject field of the email. We have You got a promo code from Make!
Under Content, write the content of the email you wish to send to the customers about the promo offer. You can see our copy on the image.
<p>Hey <span>First Name</span> !</p>
<p>Would you like to get 20% off your next purchase?</p>
<p>Here is your promo code: M@k3 @c@d3my</p>
<p>Enjoy it!</p>
You can use HTML tags if you wish to format the text.
Click here to copy our example and paste it into the content field.
Click OK to save your module configuration.
Then, save your scenario.
Scenario exercise – testing
Let’s continue and test the scenario. Work through each step before you continue.
Now that you have everything built, the time has come to test this scenario. Click Run once. A pop-up will appear in the bottom left. Click Use existing data. This means that the webhook will use the data you already sent to it from the Make Intermediate 3-3 scenario, so it’s a better option for your testing purposes.
Now let’s see what your scenario produced outside of Make! Open your email inbox. If you entered your own email address as a recipient in the Email module, you should get an email in your inbox. You’ll get as many emails as the number of times you clicked Run once in Make Intermediate 3-4 scenario. For example, you might receive an email with a subject like “You got a promo code from Make!” from noreply@make.com, containing a discount offer and a promo code.
If you are happy with both scenarios, you can activate them. To activate the scenario, toggle the schedule button to ON. Notice that in the Make Intermediate 3-4 scenario you will get a pop-up asking you to choose whether you want to process old data first or only process new data. Old data in this case refers to the data you sent through HTTP POST from Make Intermediate 3-3 scenario. New data would be every new customer registering for the newsletter.
If both of your scenarios are active, every time a new customer subscribes for the newsletter, the webhook should be triggered automatically and the customers would get an email.
Element - text / text and image (Portrait) - LARGE
As you have seen, Make Intermediate 3-3 and Make Intermediate 3-4 scenarios are interlinked, as Make Intermediate 3-3 scenario triggers the Make Intermediate 3-4 scenario, without you having to interfere manually.
The HTTP module in Make Intermediate 3-3 scenario triggers the webhook in Make Intermediate 3-4 scenario. The webhook then runs instantly once triggered. The webhook scenario only runs when it gets new data. If there is no new data coming to the webhook, the scenario does not run.