dify icon indicating copy to clipboard operation
dify copied to clipboard

[Embedded chatbot] GET input params passed in iframe src are lost after clicking "Reset Conversation"

Open johnpccd opened this issue 1 year ago • 5 comments

Self Checks

  • [X] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [X] I have searched for existing issues search for existing issues, including closed ones.
  • [X] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [X] Please do not modify this template :) and fill in all the required fields.

Dify version

0.11.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Embed a chatbot on a website using an iframe. Pass input values as GET params as per this PR. This requires gzipping and base64 encoding the values before sending. Open the website, chatbot works fine the first time. Press Reset Conversation

✔️ Expected Behavior

The conversation is restarted with the same input variables as before

❌ Actual Behavior

The input values are cleared

johnpccd avatar Nov 24 '24 01:11 johnpccd

The issue you're experiencing is that the input parameters passed via the iframe src are not retained after clicking "Reset Conversation." This happens because the current implementation of the reset functionality does not reapply the input parameters after a reset.

To address this, you can leverage the session management mechanism provided by Dify, specifically the "Conversation Variables" feature. This allows you to temporarily store information within the same Chatflow session, ensuring it can be referenced across multiple rounds of chatting. By using conversation variables, you can retain the input parameters and reinitialize them after a reset [1].

Additionally, you might need to modify the handleRestart function or the related logic to ensure that the input parameters are reapplied when the conversation is reset. This could involve storing the initial input parameters in a persistent state or variable that is not cleared during the reset process and then reapplying them when initializing the new session.

To continue talking to Dosu, mention @dosu.

dosubot[bot] avatar Nov 24 '24 01:11 dosubot[bot]

The issue you're experiencing is that the input parameters passed via the iframe src are not retained after clicking "Reset Conversation." This happens because the current implementation of the reset functionality does not reapply the input parameters after a reset.

To address this, you can leverage the session management mechanism provided by Dify, specifically the "Conversation Variables" feature. This allows you to temporarily store information within the same Chatflow session, ensuring it can be referenced across multiple rounds of chatting. By using conversation variables, you can retain the input parameters and reinitialize them after a reset [1].

Additionally, you might need to modify the handleRestart function or the related logic to ensure that the input parameters are reapplied when the conversation is reset. This could involve storing the initial input parameters in a persistent state or variable that is not cleared during the reset process and then reapplying them when initializing the new session.

To continue talking to Dosu, mention @dosu.

Conversation Variables are (and should) not be retained when you click "Reset Conversation"

johnpccd avatar Nov 24 '24 01:11 johnpccd

Duplicated https://github.com/langgenius/dify/issues/11025

crazywoola avatar Dec 05 '24 00:12 crazywoola

Appreciated, but added to Conversation Variables and assigned with the Variable Assigner as the Docs show and still the same issue: once reset, the variables disappear. The result in real life is that all links no longer work (we need to use the domain on which its embedded to create the correct links).

It's very good by itself, but unfortunately not very helpful - using the cloud hosted version, anyway - to actually integrate into anything else to create a proper help bot that knows where its embedded and who its talking to - and I'm way too dumb to be able to program something like that myself, unfortunately ;) I guarantee if there was a simple way to make it take data from the embed script or when initialized that were constant, regardless of a reset of conversation which humans do a lot to clean their slates, it would be a rocking' tool.

polischool avatar Dec 05 '24 01:12 polischool

Maybe the easiest option would be to trigger a reload of the frame when clicking the reset button.

ShadowL360 avatar Dec 15 '24 22:12 ShadowL360

Hi, @johnpccd. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • The issue involves an embedded chatbot losing input parameters after "Reset Conversation" in Dify v0.11.2.
  • I suggested using "Conversation Variables," but you noted they shouldn't persist post-reset.
  • Crazywoola identified this as a duplicate issue, while polischool confirmed the problem persists.
  • ShadowL360 proposed reloading the frame as a potential solution.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of Dify. If so, you can keep the discussion open by commenting here.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Jan 22 '25 16:01 dosubot[bot]