-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Method sendImage in Adapter API #996
Conversation
One problem I can foresee is that the images will have to be local to be able to upload them to Telegram (as an example). It might be better to have an option in the adapter like SEND_RAW_IMAGE=1 which will check the URL and if it's an image it will download it to a temporary storage and then forward it as an image. Doing it that way will allow existing Hubot scripts to benefit without breaking backwards compatibility or refactoring them. |
Initial reaction: I'm nervous about expanding the Adapter API I'll keep thinking on this and try to provide more thoughts when I have time... |
In general an API call for sending local files would be handy. I can imagine many use-cases. But this seems to be about sending images only and from a web source. That I guess is quite unique to Telegram. If that's the case no one else will implement it. As to an API for sending local files I can imagine something like this: |
👍 I was going to say the same thing -- a file sending API would be wondeful, especially for the clients that have some methods of file upload. If enough services differentiate display of files by type, then I suppose that could be some optional parameter, but it seems like that logic would be adapter dependent and not necessarily need to be in Hubot. |
I really like the idea of a generic sendFiles API like @sdimkov said.
The only problem I see now is that files should be an array of objects because every file can have metadata like filename, mime, etc. so we can find programmatically if we have to send a photo, video, audio... |
In this example, what is
I get a little nervous too. I'm wondering how many scripts could be updated to use this instead of just sending a URL. I'm also wonder if the default implementation is to just send a URL of the thing. |
I'm new to hubot development, is there really no way for an adapter to declare some custom extension methods that can then be used (or maybe gracefully degraded) by custom scripts? the telegram API also allows you to send 'stickers' which is just a file_id of something that already exists on their system. the telegram bot API is quite sophisticated with custom keyboards and many extensions beyond just text. It really is what hubot needs as a platform - they are fully supporting the bot revolution. as well as Telegram, WeChat, LINE, KAKAOTalk and all the consumer messaging platforms are adding special features that add so much to a bot experience. Stickers for example are really just table stakes for an IM platform nowadays... lowest common denominator is good for inter-op but I would prefer if that decision was up to the library user. For a consumer app a text-only bot is a non-starter, so I guess that rules out using hubot outside of ascii apps. |
There is no way as in no way currently implemented. The methods have been proposed so far are all about sending something back to the user. That is the Response class where One thought I'm having is something like:
When listeners are called, they'd use At this point, there's no changes to hubot's core itself. At most, it might be making sure that I think the hard part is what happens when multiple adapters try to introduce the same methods that have different semantics. |
I'm wondering if we can have a graceful degradation adapter that would render to the best availability of the client. that's kind of what adapters usually do like a HAL . ie you don't only support the lowest common denominator but you let the adapter be smart about how it renders - text only? graphics? eg the protocol may say:
in a text only client it shows just like that, and the user has to type in "Y" or "yes" but in a richer client like Telegram with custom keyboards, we could actually render that as a real menu with choices. For the next gen of Conversational UIs hubot could be a great core piece of infra, but without the capability to be extensible it's not usable. I actually did a small video presentation on these scalable graphical Chat UIs at the meteor devshop in SF recently: https://youtu.be/EGf665Fleko?t=4355 appreciate the brain trust here thoughts on good design patterns to enable something like these extensions without messing up the Hubot ecosystem! |
We do do this to some extent already, but very minimally. There is an
Those custom keyboards are really interesting. I think the hard part with this is going to be coming up with a language for describing high level chat concepts, that gracefully degrade for simpler chat protocols (ie IRC). In this case, I'd suggest something like The hard part with that particular workflow is that hubot would need a way have a one-off listener. Text clients would have to wait for text matching yes or no, but only once. There's been some issues and PRs around it, but nothing conclusive yet. Another potentially difficult thing about this is considering how the chat bot sees the selections from custom keyboard messages. Does it effectively send back text, or does it send a different message type? We already have a problem in hubot with adapters wanting or needing to do their own custom messages, and how to create listeners for them. |
thanks for the thoughtful response
in the case of telegram the response IS the text. WYSIWYG. the protocol could be text, such that at a worse case would just be presented as is, so its like a human legible protocol. you dont have JSON with menus and stuff, you just have:
like an old unix or, we could have content in chats marked as "metadata" for certain clients by just wrapping in
then really dumb clients and old adapter codebase would not render the { buttons } stuff and so this is more around the markup for how richer bots could be made, but that is quite a bottleneck for these projects. |
@dcsan would you mind opening an issue to discuss |
@lukefx you mentioned this is for the telegram adapter. Is this for their sendPhoto bot method? If so, it looks like that can take an uploaded file or an existing id. I don't see how supporting We've touched on it, but it seems like we need to just support something like If there are adapters that would want to customize how an image is uploaded, it might make sense then to add |
done: #1036 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR is only to start a discussion, with the new Telegram bot API (https://github.com/lukefx/hubot-telegram) I've done an adapter to interact with the Telegram IM app, It's mainly used on mobile devices and it's possible to send and receive images.
At the moment it's not possible to do so with Hubot, you could send back and URL and usually the chat service will expand it to show the image.
Could we add the ability to do it natively? I've attached a proposal that works from my fork, but I would like to see what you think about it.
Example of scripts that reply with an image: