You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/developers/webhooks-and-events/creating-webhooks.md
+23-9Lines changed: 23 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,14 +13,26 @@ topics:
13
13
14
14
15
15
16
-
Now that we understand [the basics of webhooks][webhooks-overview], let's go through the process of building out our own webhookpowered integration. In this tutorial, we'll create a repository webhook that will be responsible for listing out how popular our repository is, based on the number of Issues it receives per day.
16
+
Now that we understand [the basics of webhooks][webhooks-overview], let's go through the process of building out our own webhook-powered integration. In this tutorial, we'll create a repository webhook that will be responsible for listing out how popular our repository is, based on the number of issues it receives per day.
17
17
18
-
Creating a webhook is a two-step process. You'll first need to set up how you want your webhook to behave through {% data variables.product.product_name %}--what events should it listen to. After that, you'll set up your server to receive and manage the payload.
18
+
Creating a webhook is a two-step process. You'll first need to set up how you want your webhook to behave through {% data variables.product.product_name %}: what events should it listen to. After that, you'll set up your server to receive and manage the payload.
19
19
20
20
21
21
{% data reusables.webhooks.webhooks-rest-api-links %}
22
22
23
-
### Setting up a Webhook
23
+
### Exposing localhost to the internet
24
+
25
+
For the purposes of this tutorial, we're going to use a local server to receive messages from {% data variables.product.prodname_dotcom %}. So, first of all, we need to expose our local development environment to the internet. We'll use ngrok to do this. ngrok is available, free of charge, for all major operating systems. For more information, see [the ngrok download page](https://ngrok.com/download).
26
+
27
+
After installing ngrok, you can expose your localhost by running `./ngrok http 4567` on the command line. 4567 is the port number on which our server will listen for messages. You should see a line that looks something like this:
Make a note of the `*.ngrok.io` URL. We'll use it to set up our webhook.
34
+
35
+
### Setting up a webhook
24
36
25
37
You can install webhooks on an organization or on a specific repository.
26
38
@@ -34,17 +46,17 @@ Webhooks require a few configuration options before you can make use of them. We
34
46
35
47
{% data reusables.webhooks.payload_url %}
36
48
37
-
Since we're developing locally for our tutorial, let's set it to `http://localhost:4567/payload`. We'll explain why in the [Configuring Your Server](/webhooks/configuring/) docs.
49
+
Since we're developing locally for our tutorial, we'll set it to the `*.ngrok.io` URL, followed by `/payload`. For example, `http://7e9ea9dc.ngrok.io/payload`.
38
50
39
-
### Content Type
51
+
### Content type
40
52
41
53
{% data reusables.webhooks.content_type %} For this tutorial, the default content type of `application/json` is fine.
42
54
43
55
### Secret
44
56
45
57
{% data reusables.webhooks.secret %}
46
58
47
-
### SSL Verification
59
+
### SSL verification
48
60
49
61
{% data reusables.webhooks.webhooks_ssl %}
50
62
@@ -58,11 +70,13 @@ Events are at the core of webhooks. These webhooks fire whenever a certain actio
58
70
59
71
A full list of webhook events, and when they execute, can be found in [the webhooks API][hooks-api] reference.
60
72
61
-
Since our webhook is dealing with Issues in a repository, we'll click **Let me select individual events** and then **Issues**. Make sure you select **Active** to receive issue events for triggered webhooks. You can also select all events using the default option.
73
+
Since our webhook is dealing with issues in a repository, we'll click **Let me select individual events** and then **Issues**. Make sure you select **Active** to receive issue events for triggered webhooks. You can also select all events using the default option.
74
+
75
+
When you're finished, click **Add webhook**.
62
76
63
-
When you're finished, click **Add webhook**. Phew! Now that you created the webhook, it's time to set up our local server to test the webhook. Head on over to [Configuring Your Server](/webhooks/configuring/) to learn how to do that.
77
+
Now that you've created the webhook, it's time to set up our local server to test the webhook. Head on over to [Configuring Your Server](/webhooks/configuring/) to learn how to do that.
64
78
65
-
#### Wildcard Event
79
+
#### Wildcard event
66
80
67
81
To configure a webhook for all events, use the wildcard (`*`) character to specify the webhook events. When you add the wildcard event, we'll replace any existing events you have configured with the wildcard event and send you payloads for all supported events. You'll also automatically get any new events we might add in the future.
0 commit comments