grammyjs/conversations

Can I start a conversation from a `callbackQuery`?

dadatuputi opened this issue · 3 comments

In all the documentation I'm seeing conversation.enter in a bot.command function. I'm trying to start a conversation as a result of a button push, but when I do, the context doesn't have the registered conversations, with the error Error: The conversation 'greeting' has not been registered! Known conversations are: .

For added context about what I'm trying to do -

I have a folder of telegram commands - each one has exported objects of name, description, and execute (example).

In my bot init code, I register the execute object function as a command here, and then register all the members of the callbacks and convos exported objects, which are functions, here and here.

This method works great for executing commands and callbacks, however when I have my callback try to enter a conversation, such as here, I get the error as above.

I hope that helps. I may be missing something, or it may just be that it is impossible to do what I'm trying to do.

Thanks for any advice.

The conversation has to be registered before the callback handler for it to work properly.
You receive this error because, when your handler runs, the conversation is not yet registered, thus it doesn't exist.

Yep - that was it! I swapped the location of my for loop registering conversations and placed it above the loop registering callbacks.

Thanks for the quick answer.