# Webhooks

To show the workings of webhooks, we'll try and integrate webhooks with **Discord**

## Example: Discord Notifications with Webhooks

#### Pre-requisites

* A Discord Server with access to create Webhook URLs
* BugBase Company Account with an Active Program

**Helpful Links**

{% content-ref url="/pages/9E9NQhwIg1plgHh2NFf5" %}
[Create a Company Account](/company-guide/create-a-company-account.md)
{% endcontent-ref %}

{% content-ref url="/pages/gt84QZChY5gJbxytLzR1" %}
[Programs at BugBase](/overview/programs-at-bugbase.md)
{% endcontent-ref %}

{% embed url="<https://support.discord.com/hc/en-us/articles/204849977-How-do-I-create-a-server->" %}

## Creating a Webhook - Discord

> Before starting the setup, ensure you are logged into your Discord Account and have alteast 1 channel in your Discord server.

1. Create a new channel (or you can use an existing one) in your Discord server.![](https://file+.vscode-resource.vscode-cdn.net/var/folders/s9/x3jft3yj0bl3wn5x3918k38r0000gp/T/TemporaryItems/NSIRD_screencaptureui_HWtlJL/Screenshot%202023-02-13%20at%203.49.44%20PM.png?version%3D1676283596505)

> For this example we will use the `#bugbase-webhook` channel.

2. Click on the settings for the channel, navigate to the integrations tab and click on add a new webhook `channel > settings > integrations > create webhook`
3. Once you click on `Create Webhook` a page will open asking you to enter a name for the webhook and choose a channel. Enter a name for the webhook and select the `#bugbase-webhook` channel.

<figure><img src="/files/oNvnUrRpk0Dj8MNW2moh" alt=""><figcaption></figcaption></figure>

4. Click on the `Save Changes` button and copy the webhook URL. The webhook URL will look something like this: `https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz`

## Adding the Discord Webhook in BugBase

1. Navigate to the integrations tab located in the settings page of your BugBase Program.
2. Click on the `Add` button on the Webhooks Integration Card.
3. A modal will appear in which you will need to enter the `Webhook URL`, `params`, `headers`, `triggers` and the `body`.

<figure><img src="/files/l5Xg4CvR1yaNZDtQmhmA" alt=""><figcaption></figcaption></figure>

4. Enter your `Webhook URL` and choose the method as `POST`. The `params` and `headers` are optional.

> Discord provides it's **Webhook execution** documentation, refer the embed below

{% embed url="<https://discord.com/developers/docs/resources/webhook#execute-webhook>" %}

5. You can select multiple triggers for your webhook. The list of all available triggers are given below:

### List of triggers for your webhooks:

> **For Reports**

* `New Report is Submitted`
* `Report is Triaged`
* `Report priority is changed`
* `New message sent in report chat`
* `Reward is assigned to the Report`
* `Report is marked as Duplicate`
* `Report is marked as Invalid`
* `Report is marked as Resolved`
* `Report is marked as Informational`
* `Report is Closed`

> **For Vulnerabilities**

* `New Vulnerability is Reported`
* `Vulnerability is marked as Resolved`
* `Vulnerability is marked as Ignored`
* `Vulnerability is marked as Unresolved`
* `Vulnerability is Retested`

&#x20;

### Using Template Variables

You can use **template variables** in your webhook body to dynamically insert report or vulnerability data. Wrap variable names in double curly braces `{{variableName}}` and they will be replaced with actual values when the webhook is triggered.

#### Available Variables for Reports

| Variable          | Description                                         |
| ----------------- | --------------------------------------------------- |
| `{{trigger}}`     | The trigger label (e.g., "New Report is submitted") |
| `{{reportID}}`    | The unique ID of the report                         |
| `{{description}}` | The report description                              |
| `{{report}}`      | The full report content                             |
| `{{summary}}`     | Executive summary of the report                     |
| `{{impact}}`      | Impact description                                  |
| `{{username}}`    | Username of the reporter                            |
| `{{category}}`    | Category of the vulnerability                       |
| `{{scope}}`       | The asset/scope URL                                 |
| `{{severity}}`    | Severity level of the report                        |
| `{{status}}`      | Current status of the report                        |
| `{{priority}}`    | Priority level                                      |
| `{{timestamp}}`   | ISO timestamp of when the webhook was triggered     |
| `{{triageTime}}`  | Time when report was triaged                        |
| `{{isPrivate}}`   | Whether the report is private                       |
| `{{isClosed}}`    | Whether the report is closed                        |

#### Example: Static Message

In this example we would be using the `New Report is Submitted` trigger so that whenever a new report is submitted we will send a message to the Discord channel.

6. For the `body` of this webhook we will use the following template:

```json
{
  "content": "Hey! Please check your dashboard",
  "username": "BugBase Webhook"
}
```

Alternatively, discord also supports embeds

```json
{
  "username": "BugBase Webhook",
  "embeds": [
    {
      "description": "Please check BugBase dashboard",
      "title": "A new bug reported!"
    }
  ]
}
```

Use template variables to include report details in your webhook:

{% code overflow="wrap" %}

```json
{
  "content": "🐛 New bug reported by **{{username}}**!\n\nSeverity: {{severity}}\nCategory: {{category}}\nScope: {{scope}}",
  "username": "BugBase Webhook"
}
```

{% endcode %}

Embeds with template variables

```json
{
  "username": "BugBase Webhook",
  "embeds": [
    {
      "title": "🐛 New Bug Report - {{severity}} Severity",
      "description": "A new vulnerability has been reported",
      "color": 15158332,
      "fields": [
        {
          "name": "Reporter",
          "value": "{{username}}",
          "inline": true
        },
        {
          "name": "Category",
          "value": "{{category}}",
          "inline": true
        },
        {
          "name": "Severity",
          "value": "{{severity}}",
          "inline": true
        },
        {
          "name": "Scope",
          "value": "{{scope}}",
          "inline": false
        },
        {
          "name": "Report ID",
          "value": "{{reportID}}",
          "inline": true
        },
        {
          "name": "Status",
          "value": "{{status}}",
          "inline": true
        }
      ],
      "footer": {
        "text": "Triggered at {{timestamp}}"
      }
    }
  ]
}
```

{% hint style="info" %}
**Note:** If a variable name is not recognized, the placeholder (e.g., `{{unknown}}`) will be left unchanged in the output.
{% endhint %}

7. Click on the `Save` / `Update` button. This will set the webhook up in BugBase.
8. You can enable/disable the webhook as per your need.

<figure><img src="/files/AAnyShrhQfvzzYYQfG3m" alt=""><figcaption></figcaption></figure>

*Now the Webhook will send a message on Discord whenever a new report is submitted.*

**Preview of the Webhook**

> Simple Message

![Popup](/files/3xGK55syqsnf26Mlvo07)

> Embed

![Embed](/files/k1fhjF4KSw1kI4dJDk5r)

{% hint style="success" %}
:tada: Congratulations! You've successfully integrated a **Webhook** with your **BugBase Program**
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bugbase.ai/integrations/webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
