How do I process the answer to a question?


My handler callback:

func (b *Bot) HandleView(bot *tgbotapi.BotAPI, update tgbotapi.Update) error {
    zap.L().Debug("handler", zap.Reflect("HandleView", update))

    smileSearch := "\xF0\x9F\x94\x8E\t"

    text := fmt.Sprintf("%v <b>Please enter phrase</b>\n\n", smileSearch)

    msg := tgbotapi.NewMessage(update.CallbackQuery.From.ID, text)
    msg.ParseMode = "html"

    if _, err := bot.Send(msg); err != nil {
        return err

    return nil

I need the user input to be processed in a separate handler. How to do it on golang ?

When the HandleView function runs, the user has to enter something. How do I set a handler for this input?

i used golang and ""


You should get updates from the telegram server by one of two methods, polling or webhook. Each pair is explained on the GitHub page with an example.

Also, you may need to make a connection between the reply from the user and the message you sent. for example, you can save your message’s id that was obtained after sending and ask the user to send his answer by using the reply feature to your message. Then you can tell from comparing MessageID that the answer is related to that message.

Answered By – smorz

Answer Checked By – Katrina (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.