grammyjs / conversations

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

Loosing ctx.conversation after first conversation update #74

Closed sc0ch closed 1 year ago

sc0ch commented 1 year ago

Conversation function:

async function (conversation, ctx) { console.log(ctx.conversation, 'first update') // Ask the user for their home address. await ctx.reply("Could you state your home address?");

    // Wait for the user to send their address:
    const userHomeAddressContext = await conversation.wait();

    console.log(ctx.conversation, 'second update')
    // Ask the user for their nationality.
    await ctx.reply("Could you also please state your nationality?");

    // Wait for the user to state their nationality:
    const userNationalityContext = await conversation.wait();

    console.log(ctx.conversation, 'third update')
    await ctx.reply(
      "That was the final step. Now that I have received all relevant information, I will forward them to our team for review. Thank you!",
    );

}

Console.log data: [ First message to bot] ConversationControls { enter: [AsyncFunction (anonymous)],

ids: Set(1) { 'auth' },
session: [AsyncFunction (anonymous)]

} } first update ... [ Second message to bot] undefined first update undefined second update .. [ Third message to bot] undefined first update undefined second update undefined third update

@grammyjs/conversations@1.1.1

KnorpelSenf commented 1 year ago

This the the correct and intended behaviour. Why are you sharing this?

sc0ch commented 1 year ago

Because i'm can't enter to other conversation after any update in that. What is the right way to do this?

KnorpelSenf commented 1 year ago

You generally should not call enter when you're already inside a conversation. There's no point to that, because enter makes you enter a conversation when you're not inside one.

If you want to jump from one conversation to another, use regular JS function calls: https://grammy.dev/plugins/conversations.html#functions-and-recursion

KnorpelSenf commented 1 year ago

Feel free to reopen if you have further questions.