Conversations not ending
Opened this issue · 2 comments
Hey there,
This is my first conversation with grammy, so I started with a small example (see below).
My problem is that the conversation keeps on waiting for new input and never ends.
Does anyone experienced this behaviour before and has a clue where the problem my come from?
export async function greeting(conversation: MyConversation, ctx: MyContext) {
await ctx.reply("Hi there! What is your name?");
const { message } = await conversation.wait();
await ctx.reply(`Welcome to the chat, ${message.text}!`);
return
}
This is my multi session redis based store definition
bot.use(session({
type: 'multi',
custom: {
initial: initBotSession,
storage: new UPRedisAdapter<MySession['custom']>({ instance: getClient(), prefix: `${environment}:session#` })
},
conversation: {
storage: new UPRedisAdapter({ instance: getClient(), prefix: `${environment}:conversation#` })
}
}));
and how I add the conversation to the bot
// Install the conversations plugin.
bot.use(conversations());
bot.use(createConversation(greeting, GREETING_CONV));
Seems to be a problem with multi sessions. After changing my session config it is working "the conversation stops".
The code around that problem is quite complex for me, but maybe the problem is due to fact that session.conversation is set to undefined but it is not saved to redis storage? At least that is what I have experience.
BR, Carsten
bot.use(session({
type: 'single',
// custom: {
initial: initBotSession,
storage: new UPRedisAdapter<MySession>({ instance: getClient(), prefix: `${environment}:session#` })
// },
// conversation: {
// storage: new UPRedisAdapter({ instance: getClient(), prefix: `${environment}:conversation#` })
// }
}));
This needs investigation