I have a problem with Conversation. I wrote the following code in Conversation:
if (ctx.session.in_conversation == true) return;
conversation.session.in_conversation = true;
await ctx.replyWithChatAction("typing");
await ctx.reply("Mahsulot nomini kiriting:", {
reply_markup: cancelKeyboard,
});
const nameMsg = await conversation.waitFor(["message"], {
otherwise: () => ctx.reply("Iltimos matn ko'rinishida kiriting!"),
});
const name = nameMsg.message?.text;
if (name == "β Bekor qilish") {
conversation.session.in_conversation = false;
await ctx.reply("π
ββοΈ Amal bekor qilindi", { reply_markup: mainKeyboard });
return;
}
await ctx.reply("Mahsulot haqida ma'lumot:");
const descryptionMsg = await conversation.waitFor(["message"]);
let descryption = descryptionMsg.message.text;
await ctx.reply(`${descryption}`);
conversation.session.in_conversation = false;
return;
Conversation is stopping by itself without returning any error.
await ctx.reply("Mahsulot haqida ma'lumot:");
The text has been sent and the conversation is stuck. Where did I go wrong?
All are working until 2nd reply. But nothing is working after that. replies, conversation logs ... nothing. I solved the previous ones by completely deleting the conversation or rebuilding the project from 0.
1 Answer 1
it happening because you are using multisession, it requires an additional initial value for conversations, here`s docs https://grammy.dev/plugins/conversations#installation-with-multi-sessions
bot.use(session({
type: 'multi',
isRegistred: {
initial: () => false
},
isAdmin: {
initial: () => false
},
conversation: {}
}))
Comments
Explore related questions
See similar questions with these tags.