Outgoing Webhook is not working

Description

Hello everyone.
I have an Outgoing webhook, that triggered on SendMessage in all_public_channels.
But when I send a message, nothing happens.
In the logs you can see, that rocket chat cannot determine room ID:
{"level":20,"time":"2024-09-16T09:52:08.903Z","pid":3696,"hostname":"rocket-chat","name":"Integrations","section":"Outgoing WebHook","msg":"Starting search for triggers for the room: undefined"}

What can I do about it?

Server Setup Information

  • Version of Rocket.Chat Server: 6.12.0
  • Operating System: ubuntu 22.04.2
  • Deployment Method: snap
  • Number of Running Instances: 1
  • Proxy: nginx
  • Firewalls involved: ufw

Any additional Information

{"level":20,"time":"2024-09-16T09:52:08.903Z","pid":3696,"hostname":"rocket-chat","name":"Integrations","section":"Outgoing WebHook","msg":"Execute Trigger:","arg":"sendMessage"}
{"level":20,"time":"2024-09-16T09:52:08.903Z","pid":3696,"hostname":"rocket-chat","name":"Integrations","section":"Outgoing WebHook","msg":"Got the event arguments for the event: sendMessage","argObject":{"event":"sendMessage","message":{"_id":"eQYcQHmhGeqXvoqsd","rid":"64932124c6ad88defc820a60","msg":"dfgdfgzdfgzdfgzdfgz","ts":"2024-09-16T09:52:08.676Z","u":{"_id":"2E4LNngKkFmFtFvK6","username":"inbsp","name":"Sergey Puzyrev"},"_updatedAt":"2024-09-16T09:52:08.699Z","urls":[],"mentions":[],"channels":[],"md":[{"type":"PARAGRAPH","value":[{"type":"PLAIN_TEXT","value":"dfgdfgzdfgzdfgzdfgz"}]}]},"room":{"room":{"_id":"64932124c6ad88defc820a60","fname":"Sergey_Puzyrev","_updatedAt":"2024-09-16T09:51:43.392Z","customFields":{},"name":"Sergey_Puzyrev","t":"c","msgs":125,"usersCount":4,"u":{"_id":"d9XoyvF8hZRoGsSKr","username":"n8n.importer","name":"n8n.importer"},"ts":"2023-06-21T16:11:16.935Z","ro":false,"default":false,"sysMes":true,"lastMessage":{"_id":"A77zfa84xqDEConSs","rid":"64932124c6ad88defc820a60","msg":"dsadsaadsadsads","ts":"2024-09-16T09:51:43.167Z","u":{"_id":"2E4LNngKkFmFtFvK6","username":"inbsp","name":"Sergey Puzyrev"},"_updatedAt":"2024-09-16T09:51:43.190Z","urls":[],"mentions":[],"channels":[],"md":[{"type":"PARAGRAPH","value":[{"type":"PLAIN_TEXT","value":"dsadsaadsadsads"}]}]},"lm":"2024-09-16T09:51:43.167Z"},"roomUpdater":{"dirty":false,"_inc":{},"_set":{}}}}}
{"level":20,"time":"2024-09-16T09:52:08.903Z","pid":3696,"hostname":"rocket-chat","name":"Integrations","section":"Outgoing WebHook","msg":"Starting search for triggers for the room: undefined"}
{"level":20,"time":"2024-09-16T09:52:08.903Z","pid":3696,"hostname":"rocket-chat","name":"Integrations","section":"Outgoing WebHook","msg":"Found 0 to iterate over and see if the match the event."}

Hmmm.

First it would be handy to see your JS that is triggered.

eg this:

https://docs.rocket.chat/docs/integrations#outgoing-webhook-script

I think the format for your message is here:

https://developer.rocket.chat/apidocs/send-message

Set up an account here to test:

https://apiexplorer.support.rocket.chat/

Script:

class Script {
  /**
   * @params {object} request
   */
  process_incoming_request({ request }) {
    // Payload
    const data = {
      token: request.headers['x-rocketchat-token'], // Token for authentication (if needed)
      bot: request.user.isBot ? true : false,       // Check if the message is from a bot
      channel_id: request.room._id,                 // Channel ID
      channel_name: request.room.name,              // Channel name
      message_id: request.message._id,              // Message ID
      timestamp: request.message.ts,                // Timestamp of the message
      user_id: request.user._id,                    // User ID
      user_name: request.user.username,             // Username of the sender
      text: request.message.msg,                    // The message content
      siteUrl: request.siteUrl,                     // URL of the Rocket.Chat server
      alias: request.message.alias || null          // Alias of the sender (if any)
    };

    // Log
    console.log('Outgoing webhook payload:', data);

    return {
      content: {
        text: `captured: ${JSON.stringify(data, null, 2)}`
      }
    };
  }
}

I also tried without script and just with a script from docs example. I recreated integration. Nothing seems to change anything. Last time integration worked was on 6th of September, and then it just stopped working.

Ah.

I thnk it is this bug which is fixed in 6.12.1 but no idea when thar will be releaded.

See here, and linked issues.

Hello again.
Now using 6.12.1, problem is not resolved.

Please follow the bug.

It is with the backend team but I have no control over that. It will get fixed when it gets fixed.

N.B. This is open source… also a very good reason to test thoroughly before committing to updates…

Thanks for the time. But I am not committed to updates by will, this was default behavior.

Problem resolved in 6.13.0 version.

1 Like