Tags | Settings | Webhooks | Integrations |
ADMIN PRIVILEGES REQUIRED
This documentation is for Stack Overflow for Teams Enterprise. Free, Basic, and Business users can access their documentation here. Find your plan.
Overview
A webhook watches activity on a site, sending an alert to another site or service when a specific activity takes place. Administrators can use webhooks to set up integrations between different tools used by their company, or trigger events on other platforms when a specific action occurs on their Stack Overflow for Teams Enterprise (SOE) site.
Enable webhooks
Before setting up your integrations, follow these steps to enable the generic webhooks feature on SOE:
Go to https://[your_site]/developer/site-settings/edit?name=Webhooks.EnableGenericWebhooks.
Change the
EnableGenericWebhooks
site setting to True.Add a brief reason for making the site settings change.
Click Save New Network Default.
Create generic webhooks
As an administror, click Admin Settings then Webhooks. Click Create a Generic Webhook to open the "Get notifications via webhooks" window.
Configure the fields as follows.
What would you like to name this webhook? Give your new webhook notification a short, descriptive name.
Which location should be used for this notification? Choose whether the webhook should monitor the main site or a Private Team (if enabled).
What activity would you like to be notified about? Select all actions that should generate the webhook notification.
What tags would you like to be notified about? Choose All tags, or Specific tags if you'd like the webhook to generate a notification only for activity in specific tags.
What community would you like to be notified about? If you'd like webhook notifications only for a specific Community, select it here.
Where would you like the payload to be sent? Enter the URL that will receive the notifications for this webhook. The site or service set up to receive the webhooks should provide this URL.
After configuring the webhook, you can optionally click Test Webhook to generate a test notification to the destination URL.
Click Create Webhook to save the settings and create the new webhook. It will appear in the webhook list.
Manage generic webhooks
The Manage webhooks page contains a list of all webhooks on your site.
Next to each webhook are links to Edit or Delete it. Click Edit to bring up a window similar to the "Get notifications via webhooks" window, where you can change the configuration of the webhook. To delete a webhook, click Delete then OK to confirm the deletion.
NOTE: If SOE detects a problem with a webhook, it will display that webhook in gray. The Edit and Delete links still work, allowing you to troubleshoot or delete the nonfunctional webhook.
Action type
When an action triggers a webhook, your SOE site sends the webhook notification in the form of a small data "payload". In this data is a type
field that identifies what action triggered the webhook.
The type
field values in each of the categories (questions, answers, and comments) are as follows:
Questions
question created
question edited
Answers
answer created
answer edited
answer accepted
Comments
comment created
Based on the type
field, the application receiving the webhook payload can take the appropriate action. For detailed examples of using generic webhooks, read the webhooks.pdf document linked at the bottom of this article. To see an example webhook payload, go to the "Example webhook payload" section below.
Webhooks site settings
You can change several global site settings that affect the functioning of all webhooks:
Webhooks.EnableGenericWebhooks
Enable or disable the generic webhooks feature.https://[your_site]/developer/site-settings/edit?name=Webhooks.EnableGenericWebhooks
Webhooks.DispatchInterval
Set how often the site should look for new events to generate notifications.https://[your_site]/developer/site-settings/edit?name=Webhooks.DispatchInterval
Webhooks.DispatchDelay
How long the site should wait before sending notifications. Longer wait times will help prevent multiple duplicate notifications for repeated similar actions.https://[your_site]/developer/site-settings/edit?name=Webhooks.DispatchDelay
Webhooks.EnableTriggerHistory
Enable or disable the logging of events that trigger webhooks. This log can be useful for troubleshooting.https://[your_site]/developer/site-settings/edit?name=Webhooks.EnableTriggerHistory
Example webhook payload
Payload contents will differ based on the trigger event, but they all follow the same structure.
{ "questions": [ { "tags": [ "tag1", "tag2" ], "owner": { "user_id": -1, "display_name": "Community" }, "score": 5, "creation_date": 1538594411651, "last_edit_date": 1538680811651, "question_id": 1, "link": "https://local.soe.com/questions/1/testing-webhooks", "title": "Testing Webhooks", "body": "This is a test for firing webhooks from Stack Overflow.", "type": "question created" } ], "answers": [ { "owner": { "user_id": -1, "display_name": "Community" }, "score": 5, "last_edit_date": 1538680811651, "creation_date": 1538594411651, "answer_id": 2, "link": "https://local.soe.com/questions/1/testing-webhooks/2#2", "body": "This is a test for firing webhooks from Stack Overflow.", "type": "answer created" } ], "comments": [ { "score": 1, "creation_date": 1538594411651, "comment_id": 3, "body": "This is a test comment for firing webhooks from Stack Overflow", "type": "comment created" } ], "type": "New activity in SE 2.0" }