grammyjs / conversations

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

conversation doesn't continue after using conversation.session #96

Closed eedea closed 5 months ago

eedea commented 5 months ago

Hi, I Used conversation.session to store data in session in middle of conversation and it looses track of conversation after sending one response!

conversation.session.facilities = await conversation.external(() =>
    facilitiesList(user.id)
  );
  await ctx.reply("please choose a facility", {
    reply_markup: facilitiesMenu,
  });
  const { session } = await conversation.waitFor("callback_query:data");
  const facilityID = session.selectedFacility;

  await ctx.reply("Please send contact number.");
  const { message } = await conversation.waitFor("message:contact");

it goes down to "await ctx.reply("Please send contact number.");" but there is no response to sending contact after it

KnorpelSenf commented 5 months ago

You have to use conversation.session always. ctx.session, which is what you're calling when you do const { session } = await conversation.wait…, is frozen in time and will not persist its changes. This is documented: https://grammy.dev/plugins/conversations#rule-iii-use-convenience-functions