hedwig-im / hedwig

An Adapter-based Bot Framework for Elixir Applications
MIT License
650 stars 73 forks source link

Defining adapter-dependent actions #81

Open dysnomian opened 6 years ago

dysnomian commented 6 years ago

tl;dr I'd like to use Slack-specific features like ephemeral messages in my responders, and I'm not sure the best approach for it. Is there a place to talk about hedwig? IRC, Gitter, Slack?

The long version:

The Slack bot in question currently uses elixir-slack, which provides a few functions that aren't currently covered by Hedwig. For example, it knows how to set a channel topic, which we used for team status and quick updates.

There are also some Slack features it doesn't implement that would be extremely useful in our bot, such as reactjis, threaded messages, and ephemeral messages.

I've implemented all these in different ways, and could fire off a bunch of pull requests for Hedwig and hedwig-slack if they'd be welcome. However, I'm not clear on how to implement them on the Hedwig side, or (maybe this is getting into the weeds a bit) whether that even fits with the Hedwig philosophy.

Suppose I want to respond to certain keywords by starting or joining a thread. Ideally, I want an ephemeral_reply helper function on the Hedwig.Responder module, and that would pass it along to the adapter. Easy peasy. But the concept of an ephemeral message doesn't exist in other adapters.

It seems like in some way, Hedwig needs to know about the existence of these kinds of actions at least enough to test them, and ideally implement them in the shared Responder helpers, but that opens a whole error handling can of worms...

scrogson commented 6 years ago

@dysnomian thanks for reaching out!

I'd love to hear a little bit more detail about what changes you would need to make in order to support your use-case. I've only ever used and intended to use the RTM API for the Slack Adapter.

Since responders are invoked asynchronously they can do anything practically anything you want already. So if you need to reply to a message via the Web API, you can do that instead and just have the responder return :ok.

If you want to chat about this further, feel free to ping me on the Elixir Slack channel. I've got a #hedwig channel there as well.

matthewoden commented 6 years ago

So I've been working around similar issues - one thing that'd be great would be access to the original message. Threading via the Web API needs fields that aren't on the Message struct.