I'm really pleased to announce the release of not only one of the most requested features on Forge, but also our first significant feature release since I took over Forge, Hammer and Anvil a few weeks ago - WebHooks are here.
Up until now, most of the changes have been in core system updates, upgrades and adjustments with a performance and processing. But that stuff is invisible and it's nice to get some shiny new toys out to play with.
So, I'm pleased to say that all sites on all Forge plans, including Free accounts, will have access to WebHooks.
We start with our first Incoming Webhook, that is, a message sent to Forge (you can have them be sent by Forge also) - for triggering a re-deployment of your site. I'll discuss more in detail about what this means and what sort of amazing things you can do, just with this simple feature alone.
What are WebHooks?
WebHooks are essentially a way to carry out some action and pass some message via an http request to a URL. You've probably come across WebHooks if you've used services like IFTTT, Zapier or setup a Slack integration .
They are a neat and easy way to trigger a real-time response to an event and pass that information to another service to carry out some action, thereby connecting services together for a better experience.
You can read more about WebHooks here if you want to dive deeper.
How can I Use Them?
Great question. And that's really the basis of this blog post, I'd like to share a couple ways in which this initial WebHook can be super fun and useful to your workflow.
First up, let's see how we can find out our WebHook for our site.
Login into your Forge account at https://getforge.com. Select one of your sites, and click the Settings tab at the top of the page.
Scroll down until you find the WebHooks section, like this:
What's in a WebHook Url?
https://getforge.com/webhook is the basic url and is consistent for all webhooks. Then we need to pass some additional parameters.
?type=redeploy which specifies the type of webhook we are generating and is closely tied to the resulting action.
url=nuwe-health.getforge.io this is the url of the site you wish to redeploy. If it's a Custom domain, simply pass that instead of the getforge.io subdomain.
token=YOUR_FORGE_USER_TOKEN this is your unique user token. Keep this safe and secure.
Basic Example Using Postman
So, to trigger our site to deploy using this webhook, it's as simple as copying and pasting the URL into the browser and hitting enter. This particular WebHook will work with both a POST and GET request method.
But, let's take a look at firing off this request first using a REST Client, like Postman.
Simply copy and paste the Webhook URL into the Postman request field, then hit Send
If the response is successful, well, it should say as such...
Head back to your Forge Site deployment timeline and you should see your new Version deployed (you may need to refresh the page if you have the window open already).
OK, ok. So that's a super simple example. So now let's do something a little more fun...
Deploy your Forge Site with a Slack Message
Do you use Slack? We do and we love it! Slack is fast replacing my inbox for most communication day-to-day.
So, what better example than showing how we can quickly wire up a Slack Slash Command, to trigger a deployment for a Forge hosted site. Let's get started...
You can see here in the Slack Slash Command creation page, that Slack will send us a certain payload with along with the information we provide in our WebHook URL.
For this example, we're not really going to use much of this. But, to make this example a little more interesting, what if I wanted to be able to tell Forge to deploy ANY of my sites with a simple little Slack command? How would I do that?
Well, we can see at the bottom of the Slack Payload a text parameter, where we can pass some additional information to Forge and use it - and that we will. Let's move on and you'll see how.
So first, let's decide on our primary slash command. That is, we would write something like
Ok, that will do nicely. So we can just enter that, for this example, in any Slack channel reply
But for that to do anything, we need to configure the rest of the Slack Command settings.
So, in the URL, we're going to copy and paste our Webhook URL again, but this time remove the reference to the specific site URL, since we want the flexibility to be able to deploy ANY site.
Finally to complete the settings, we will fill out the Description and Usage instructions to suit our liking.
So the question remains, how do we tell Forge which site to deploy? Simple, the Slash Command accepts some additional text with the command, remember the text= stuff in the payload. It comes from there.
So in Slack, we would just type
And we've setup the Forge WebHook to treat text=nuwe-health.getforge.io in the same way it would url=nuwe-health.getforge.io
If you head back into your Forge SIte Versions tab again, you should be seeing that brand spanking new shiny version.
You can now type the name of any of the sites that you own on Forge with this command in Slack and deploy until your heart's content.