hedwig-im/hedwig

Send files/attachments

jeffweiss opened this issue · 4 comments

For a few days I've been prototyping a hedwig-based bot connected to our internal data mart. I've begun to get requests from folks for more complicated responses, and in some cases requests for file attachments.

Example of current situation

Jeff Weiss: @hedwig who's running what version?
Hedwig: /code
Customer         | Version
ACME Tech        | 3.7.1
Alpha, AB        | 3.8.0
...
Zeta Industries  | 3.8.3

This might work fine for a small-ish responses, but pretty quickly becomes unwieldy. And if the folks using hedwig responses are plugging into to something else, we have to compromise between readability and integration.

I'd like your thoughts on adding the ability for file transfer/attachments for responders. Maybe something like reply_with_file(msg, text, file) or send_with_file(msg, text, file)

Example ideal interaction

Jeff Weiss: @hedwig who's running what version?
Hedwig: @jeffweiss who's running which version is a fair bit of data, so here it is as csv
<customer_versions.csv>

Necessary Adapter Changes

Based on some preliminary research, I believe that each of the existing adapters (Slack, HipChat, and IRC) could implement this new functionality.

Non-Hedwig Options

I can use technologies outside of Hedwig to accomplish this, but it requires the user to incur a switching cost as there's now an additional layer between them and what they'd asked for.

  • Send email with attachment (assuming email of asker is known/discoverable)
  • Dropbox/Box
  • Pastebin/Gist

Thoughts?

@jeffweiss I love this idea! I'll start thinking about an API for this.

@scrogson I'm wondering if it would be possible to delegate somehow the message to the adapter. As each service has its own types of messages. For example in telegram, to mention one, you can send keyboards.

I'm really asking, as a clarification for a doubt I have, I don't know if it's already in Hedwig. But I'd be a really nice API if not.

Currently at work we've developed something with AWS, kinda like a message gateway, a main entry point for receiving and sending messages (for messenger, kik, line, twilio & telegram), but this delegates to the services or adapters of this services, thus we can send special keyboards, special images, or custom responses without having any kind of limitation.

We've been wanting to change it, completely rewrite it in Elixir, so we can take advantage of what it gives us, like amazing fault tolerance software it's built upon. We were looking around, investigating when we came upon Hedwig, and we really think it could be the answer we've been looking.

Thanks for your attention.
Hope I've explained myself.

I'm wondering if it would be possible to delegate somehow the message to the adapter.

@behind-design what exactly do you have in mind?

The response messages do make their way back to the adapter which is responsible for transforming the %Hedwig.Message{} into whatever is required for the underlying service.

iref commented

I was wondering if type field on %Hedwig.Message{} would be enough to distinguish if responder wants to send normal message or message with attachment (e.g. Slack 'message.attachment' type) or file. Adapters can use pattern matching to compose message needed for their specific messaging protocol.

Is this good idea? I am Elixir/Erlang beginner, so I am not sure if there is better/more idiomatic way how to solve this in Elixir.