Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outgoing webhook questions #7008

Closed
ellisgl opened this issue May 18, 2017 · 4 comments · Fixed by #7214
Closed

Outgoing webhook questions #7008

ellisgl opened this issue May 18, 2017 · 4 comments · Fixed by #7214

Comments

@ellisgl
Copy link

ellisgl commented May 18, 2017

I'm converting an IRC bot I developed to used on Rocket.Chat, and was wondering how to how the outbound webhook send the response to the user that triggered it, instead of the channel it was sent from? But I only need it for one case, the rest would respond back to the channel.

@ellisgl ellisgl changed the title Outgoing webhook questions? Outgoing webhook questions May 19, 2017
@ellisgl
Copy link
Author

ellisgl commented May 19, 2017

For now, the work around I found is that I can reply an empty object to the outbound webhook, then fire off a inbound webhook request that has the channel: @user in the payload. But would be nice to have it supported in the outbound response.

@graywolf336
Copy link
Contributor

Is this in the script part of the outgoing integrations?

@ellisgl
Copy link
Author

ellisgl commented May 23, 2017

@graywolf336 So even if I put channel:@user in the process_outgoing_response (in the base and in the content object), it doesn't work:

    class Script
    {
        prepare_outgoing_request({ request })
        {
            let match;
            match = request.data.text.match(/^!(.*)/);

            if (match)
            {
                var args = match[1].split(' ');
                var func = args.shift();
                
                return {
                      url: request.url + '/' + func,
                      headers: request.headers,
                      method: 'POST',
                      data: {
                        args: args,
                        data: request.data
                      }
                };
            }
          
          return false;
        }

        process_outgoing_response({ request, response })
        {
            //console.log(response);
            
            if(response.hasOwnProperty('content') && response.content.hasOwnProperty('text'))
            {
                var content = {
                    content: {
                        text: (Array.isArray(response.content.text)) ? response.content.text.join("\n") : response.content.text,
                        channel: '@myusername'
                    }
                };

                return content;
            }
            else
            {
                return null;
            }
        }
    }

@graywolf336
Copy link
Contributor

@ellisgl No, sadly it is not possible to do what you're wanting right now...but I thought it used to. I'm working on something so that in the future ones it can work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants