grammyjs / conversations

Conversational interfaces for grammY.
https://grammy.dev/plugins/conversations
MIT License
48 stars 17 forks source link

Conversations not ending #76

Open came opened 1 year ago

came commented 1 year ago

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));
came commented 1 year ago

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#` })
    // }
}));
KnorpelSenf commented 1 year ago

This needs investigation