node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

listen on answer from reply_markup

Open picsoung opened this issue 10 years ago • 5 comments

hi,

Just starting to discover Telegram bot programming. Thank you for this package it works great!

I am having issues with a bot to follow a conversation and gather the answers from users.

The conversation should be: Bot: You are defining yourself as: +shows a keyboard with options: Male, Female, Other+ User clicks on one of the button. Bot receives the answer and continue to next question

To listen to user's answer I wanted use bot.on('message') but how I could make a difference between answers from question #1 and the ones from #2 ? What would you recommend for this type of conversation?

Thanks

picsoung avatar Jan 28 '16 21:01 picsoung

I devised an extension of the TelegramBot Prototype to provide this functionality in the discussion of issue #26. As mentioned in the post, you will have to manage ridding yourself of dangling eventHandlers (I'd have them time out), which is not implemented in the example, but I tested the function in a small project and it appears to work in groups and private chats.

githugger avatar Jan 29 '16 23:01 githugger

Use onReplyToMessage

yagop avatar Jan 30 '16 18:01 yagop

I wrote a little example here

yagop avatar Jan 30 '16 18:01 yagop

That's exactly what I was looking for! Thanks for your reactivity :)

On Saturday, January 30, 2016, Yago [email protected] wrote:

I wrote a little example here https://github.com/yagop/node-telegram-bot-api/blob/master/examples/replyToMessage.js

— Reply to this email directly or view it on GitHub https://github.com/yagop/node-telegram-bot-api/issues/67#issuecomment-177262266 .

Nicolas Grenié - Hacker in residence 3SCALE | Out-of-the-Box API Management Platform Tel: +1 415 351 9635 Web: http://nicolasgrenie.com Twitter: @picsoung http://twitter.com/picsoung Github: picsoung http://github.io/picsoung

picsoung avatar Jan 30 '16 19:01 picsoung

http://i.giphy.com/ljKpVuz20KgYE.gif

yagop avatar Jan 30 '16 20:01 yagop