# WebHook notifications

**URL:** <https://forum.opensearch.org/t/webhook-notifications/22305>\
**Category:** OpenSearch Dashboards\
**Created:** [November 5, 2024, 12:44pm UTC](https://forum.opensearch.org/t/webhook-notifications/22305 "2024-11-05T12:44:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DmitriiKuvshinov](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@DmitriiKuvshinov](https://forum.opensearch.org/u/DmitriiKuvshinov)\
**Post date:** [November 5, 2024, 12:44pm UTC](https://forum.opensearch.org/t/webhook-notifications/22305/1 "2024-11-05T12:44:07Z")

</div>

**Versions**  
2.17.1

**Describe the issue** :  
I want to send webhooks to our Rocket.Chat, but OpenSearch send html body, not json

**Configuration** :

```auto
{
  "start_index" : 0,
  "total_hits" : 1,
  "total_hit_relation" : "eq",
  "config_list" : [
    {
      "config_id" : "Ip75-5IBkTxtk5bkXEfE",
      "last_updated_time_ms" : 1730808888085,
      "created_time_ms" : 1730804276420,
      "config" : {
        "name" : "Rocket",
        "description" : "",
        "config_type" : "webhook",
        "is_enabled" : true,
        "webhook" : {
          "url" : "https://rocket.domain/hooks/ **webhook**",
          "header_params" : {
            "Content-Type" : "application/json"
          },
          "method" : "PUT"
        }
      }
    }
  ]
}

```

In tcpdump i see, that request contain HTML (line based text data), not json

---

<div class="post-metadata">

**Author:** ![DmitriiKuvshinov](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@DmitriiKuvshinov](https://forum.opensearch.org/u/DmitriiKuvshinov)\
**Post date:** [March 30, 2026, 8:39am UTC](https://forum.opensearch.org/t/webhook-notifications/22305/2 "2026-03-30T08:39:05Z")

</div>

So

I just resolve it on Rocket.Chat server side:

- in integration enable script
- add script in text field

```java
class Script {
  /**
   * @params {object} request
   */
  process_incoming_request({ request }) {
    // The incoming request content from OpenSearch is in request.content
    // OpenSearch might send a specific JSON structure or an HTML snippet (as noted in search results).
    // You need to inspect the payload structure to parse it correctly.

    // A common approach is to extract key information and format it:
    const alertMessage = request.content_raw; // Assuming OpenSearch sends text in a 'text' field

    // Format the message using Rocket.Chat's message structure (e.g., using attachments for rich messages)
    const rocketChatPayload = {
      text: `:alarm: *OpenSearch Alert Notification*`,
      attachments: [
        {
          title: "Alert Details",
          text: alertMessage || "No detailed message provided.",
          color: "#FF0000" // Red color for alerts
        }
      ]
    };

    // Return the formatted content
    return {
      content: rocketChatPayload
    };
  }
}

```

After that OpenSearch will deliver notification to Rocket.Chat

 ![Screenshot 2026-03-30 at 11.38.55](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/0/0e93e0f9540f0efc4ece14fa9d0b024207d4cee7.png)
