How to make Outgoing webhook respond just to the user that has send the command

Description

I would like send a outgoing webhook command and get the result just to the user that has sent the command.

Now, when I send in general channel for example, all users get the command and the response of outgoing webhook

Server Setup Information

  • Version of Rocket.Chat Server: 3.18
  • Operating System: Ubuntu
  • Deployment Method: Snap
  • Number of Running Instances: 1

Any additional Information

My current script is something like this:

class Script {

    prepare_outgoing_request({ request }) {
        return getPreparedRequest(request)
    }

    process_outgoing_response({ request, response }) {

        const linksArray = response.content.map( item => `[${item.name}](${item.url})` )
        return {
            content: {
                text: linksArray.join('\n'),
                parseUrls: false
            }
        };
    }
}

For someone with this requiment and who don’t got help too…

It is almost done: Now I get the response of outgoing webhook request just to the user that have sent the trigger work, even if that word has typed on a channel

Now I just need to stop the trigger word to be echoed on channel

process_outgoing_response({ request, response }) {

        const { user_name } = JSON.parse(request.data)
        const linksArray = response.content.map( item => `[${item.name}](${item.url})` )
        return {
            content: {
                text: linksArray.join('\n'),
                channel: `@${user_name}`, //Here is the trick, forward to the user who has trigged
                alias: "Relatórios",
                emoji: ":dividers:",
            }
        };
    }


1 Like