HTTP is not defined in outgoing webhook script

Hello,

I am working on an outgoing webhook script in Rocket.Chat and trying to make an HTTP request using the HTTP helper as described in the documentation. However, when I attempt to use HTTP, I encounter the following error:

ReferenceError: HTTP is not defined

Here is the relevant part of my script:

const apiUrl = `https://rocket.example.com/api/v1/users.info?username=${Username}`;
const apiHeaders = {
    'X-Auth-Token': 'your-auth-token', // Authentication token
    'X-User-Id': 'your-user-id' // Admin user ID
};

const response = HTTP('GET', apiUrl, { headers: apiHeaders });

I have double-checked the authentication details, and they are correct. Based on the documentation, the HTTP helper should be available for outgoing webhook scripts. However, it seems like HTTP is not recognized or defined in the script environment.

Can someone confirm:

  1. Is the HTTP helper supported in the latest version of Rocket.Chat?
  2. If it is supported, how should I correctly use it to make external HTTP requests within an outgoing webhook script?
  3. If it is not supported, is there an alternative method to perform HTTP requests in this context?

I am using Rocket.Chat version 6.13.0.

Thank you for your assistance!
Carlos

What are you trying to achieve?

Which docs are you referring too?

(You probably ought to test on v7.x +)

Hi,
I want to retrieve the email address of the user who sent the message that triggered the outgoing webhook. Specifically, I need to use the username provided in the webhook payload to query the Rocket.Chat REST API (/api/v1/users.info) and extract the user’s email.

I referred to https://docs.rocket.chat/docs/integrations

Outgoing webhook script

… Additionally, you can create another request within the script using the HTTP global helper. …

I also tried this example webhook https://docs.rocket.chat/docs/nixstats-notification with the same result.
I’m using the snap and self-hosted version of RocketChat

I’ll try and see if I can get someone to advise.

Great! Thanks!
Carlos

No idea if and when anyone will respond, but I have asked.