exciting-io / slack-bot-server

A server for running multiple slack bots -- useful for building integrations
MIT License
47 stars 13 forks source link

interactive message support #28

Closed confact closed 6 years ago

confact commented 7 years ago

I plan to use this as my bot server but I would need interactive message support.

How would I be able to support that? If you don't have time to do it yourself, could you point some way and I will try to add it, it is important for me that I can do interactive messages.

lazyatom commented 7 years ago

When you say interactive messages, do you mean messages which include buttons etc?

confact commented 7 years ago

Yes, I mean that. Now I need some way to bridge over the request from a webhook from slack via a controller, or have I misread?

If I understand it correctly I can add the buttons without problems with attachment in the reply or say method. But I would need a way to handle the action of the button. I would like to handle all the bot logic in the bot class, and not send say via remote control.

So my thought was to add a method to remote control class here for just sending the actions from the interactive message's actions to the bot. And have a method in the bot handle that.

What do you think @lazyatom?

lazyatom commented 7 years ago

In order to do that, I think you'd need to somehow enhance this whole server to be able to respond to the HTTP requests coming from Slack, which I've deliberately delimited as outside of the scope of the bot.

Because this project is designed to complement an existing app, it's the intention that you handle the HTTP requests using the existing app (e.g. with a Rails controller). From within that controller you could certainly then call methods that are defined in files that sit nearby, but it's not really correct to think about them as being received "by the bot" (and it definitely won't be the same literal object instance, since that has to run within a separate process anyway).

confact commented 7 years ago

I was a bit unclear, I will indeed use a rails controller.

The flow will look like this:

  1. Have buttons in the attachment
  2. user click on the button
  3. have a rails controller taking the webhook from slack
  4. rails controller call an remotecontrol method for the interactive message
  5. bot get the command and handle the data from the action in the method.
  6. bot respond and update the message or just do a normal reply

In that way, I would need to have a method for this in remote control and in bot. Shall I just add to my fork or how do you feel?

lazyatom commented 7 years ago

By all means please do spike some code -- it'll be easier to make sure we're talking about the same thing :)

confact commented 7 years ago

@lazyatom pushed my solution to the problem. work pretty good with a controller or a grape endpoint. Fixed also the common way to update a message when clicking on the button.