Cannot load existing conversation using iframe or embed script (conversation_id ignored) #13335

Closed
opened 2026-02-21 19:11:42 -05:00 by yindo · 8 comments
Owner

Originally created by @amarczew on GitHub (Apr 25, 2025).

Self Checks

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

Dify version

1.3.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

I'm injecting the script below to load an existing conversation_id, but the chat always starts as a new conversation, creating a new conversation_id, instead of loading the one I passed.

<script>
    window.difyChatbotConfig = {
        token: 'token',
        baseUrl: 'https://mydomain',
        systemVariables: {
            // user_id: '47433ef6-345b-4c0f-ac33-39e00de43e7d',
            conversation_id: 'e87a4c48-f72a-4150-92d7-3ba545791dee'
        },
    }
</script>

<!-- Chatbot Script -->
<script src="https://mydomain/embed.min.js" id="id" defer></script>

🧪 What I'm seeing

Even when I pass a valid conversation_id, a new conversation is started.
When I include a user_id, I can see in the network tab that the existing conversations for that user are correctly listed via:

GET /api/conversations?limit=100&pinned=false

However, when a message is sent (with the user_id present), the system still creates a new conversation_id, instead of continuing the one I specified.


What I want to achieve

In my app’s dashboard, I need to load an existing conversation_id, which was previously created by an automated backend process via API.

Current flow:

  1. Front-end calls a backend endpoint that creates a new chat via API.
  2. This endpoint returns a conversation_id.
  3. The front-end should then load the chatbot using this specific conversation_id.

Initially, I tried using an <iframe>, but it didn’t work as expected. Then I moved to embed.min.js, but got the same issue — the conversation_id is ignored and a new one is always created.


🤔 Any idea what's going wrong?

If this is not an issue, would love any guidance on how to correctly inject and resume a conversation using a known conversation_id.

✔️ Expected Behavior

When providing a valid conversation_id via window.difyChatbotConfig, the chatbot should load and resume the existing conversation, instead of creating a new one.

If both user_id and conversation_id are provided:

  • The chat should continue exactly from the given conversation_id context.
  • No new conversation_id should be created unless explicitly requested.

Actual Behavior

Even when a valid conversation_id is provided through window.difyChatbotConfig, the chatbot starts a new conversation every time it loads.

  • A new conversation_id is generated, ignoring the one passed.
  • If a user_id is provided, the API correctly fetches the list of existing conversations for that user (/api/conversations?...), but sending a message still creates a new conversation instead of continuing the specified one.

This breaks the expected behavior of resuming an existing conversation, and makes it impossible to preload or control chat history from the frontend.

Originally created by @amarczew on GitHub (Apr 25, 2025). ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.3.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce I'm injecting the script below to load an existing `conversation_id`, but the chat always starts as a **new conversation**, creating a **new `conversation_id`**, instead of loading the one I passed. ```html <script> window.difyChatbotConfig = { token: 'token', baseUrl: 'https://mydomain', systemVariables: { // user_id: '47433ef6-345b-4c0f-ac33-39e00de43e7d', conversation_id: 'e87a4c48-f72a-4150-92d7-3ba545791dee' }, } </script> <!-- Chatbot Script --> <script src="https://mydomain/embed.min.js" id="id" defer></script> ``` ### 🧪 What I'm seeing Even when I pass a valid `conversation_id`, a new conversation is started. When I include a `user_id`, I can see in the network tab that the existing conversations for that user are correctly listed via: ``` GET /api/conversations?limit=100&pinned=false ``` However, when a message is sent (with the `user_id` present), the system still creates a **new `conversation_id`**, instead of continuing the one I specified. --- ### ✅ What I want to achieve In my app’s dashboard, I need to load an **existing `conversation_id`**, which was previously created by an automated backend process via API. #### Current flow: 1. Front-end calls a backend endpoint that creates a new chat via API. 2. This endpoint returns a `conversation_id`. 3. The front-end should then load the chatbot using this specific `conversation_id`. Initially, I tried using an `<iframe>`, but it didn’t work as expected. Then I moved to `embed.min.js`, but got the same issue — the `conversation_id` is ignored and a new one is always created. --- ### 🤔 Any idea what's going wrong? If this is not an issue, would love any guidance on how to correctly inject and resume a conversation using a known `conversation_id`. ### ✔️ Expected Behavior When providing a valid `conversation_id` via `window.difyChatbotConfig`, the chatbot should load and **resume the existing conversation**, instead of creating a new one. If both `user_id` and `conversation_id` are provided: - The chat should continue exactly from the given `conversation_id` context. - No new `conversation_id` should be created unless explicitly requested. ### ❌ Actual Behavior Even when a valid `conversation_id` is provided through `window.difyChatbotConfig`, the chatbot **starts a new conversation** every time it loads. - A **new `conversation_id`** is generated, ignoring the one passed. - If a `user_id` is provided, the API correctly fetches the list of existing conversations for that user (`/api/conversations?...`), but **sending a message still creates a new conversation** instead of continuing the specified one. This breaks the expected behavior of resuming an existing conversation, and makes it impossible to preload or control chat history from the frontend.
yindo added the 🐞 bug label 2026-02-21 19:11:42 -05:00
yindo closed this issue 2026-02-21 19:11:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Apr 25, 2025):

Hello @amarczew! I'm Dosu, your friendly bot here to help you tackle bugs, answer questions, and guide you on your journey as a contributor. I'm here to assist while you wait for a human maintainer. How can I help you today?

I found a similar unsolved discussion titled "Can I initialize an embed with a conversation_id?" which might be related to your issue [1]. Additionally, there is a closed issue titled "Restore and continue the conversation in historical dialogues(logs)" but no solution was found in the comments [2].

Regarding your issue, here are some points to consider:

  1. Valid conversation_id: Ensure that the conversation_id you are using is a valid UUID and was generated by the system in a previous API call. Custom or user-defined conversation_ids will not be recognized and will result in a new conversation being started [3].

  2. Configuration: The conversation_id should be correctly set in the systemVariables object within the difyChatbotConfig configuration. Ensure that there are no conflicts with existing data in the system [3].

  3. Memory Feature: To resume conversations using a conversation_id, ensure that the memory feature is enabled for both Agent and LLM nodes. This involves configuring the 'history-messages' feature in the Agent plugin's YAML configuration file and enabling the Memory toggle in the interface [4].

If these points do not resolve the issue, it might be worth checking if there are any specific error messages or logs generated by the embed.min.js script when a conversation_id is ignored or not recognized, as this could provide further insights into the problem.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Apr 25, 2025): <!-- Greeting --> Hello @amarczew! I'm [Dosu](https://dosu.dev), your friendly bot here to help you tackle bugs, answer questions, and guide you on your journey as a contributor. I'm here to assist while you wait for a human maintainer. How can I help you today? <!-- Answer --> I found a similar unsolved discussion titled "[Can I initialize an embed with a conversation_id?](https://github.com/langgenius/dify/discussions/9385)" which might be related to your issue <sup>[[1]](https://github.com/langgenius/dify/discussions/9385)</sup>. Additionally, there is a closed issue titled "[Restore and continue the conversation in historical dialogues(logs)](https://github.com/langgenius/dify/issues/12141)" but no solution was found in the comments <sup>[[2]](https://github.com/langgenius/dify/issues/12141)</sup>. Regarding your issue, here are some points to consider: 1. **Valid `conversation_id`**: Ensure that the `conversation_id` you are using is a valid UUID and was generated by the system in a previous API call. Custom or user-defined `conversation_id`s will not be recognized and will result in a new conversation being started <sup>[[3]](https://github.com/langgenius/dify/issues/11637)</sup>. 2. **Configuration**: The `conversation_id` should be correctly set in the `systemVariables` object within the `difyChatbotConfig` configuration. Ensure that there are no conflicts with existing data in the system <sup>[[3]](https://github.com/langgenius/dify/issues/11637)</sup>. 3. **Memory Feature**: To resume conversations using a `conversation_id`, ensure that the memory feature is enabled for both Agent and LLM nodes. This involves configuring the 'history-messages' feature in the Agent plugin's YAML configuration file and enabling the Memory toggle in the interface <sup>[[4]](https://github.com/langgenius/dify/issues/18562)</sup>. If these points do not resolve the issue, it might be worth checking if there are any specific error messages or logs generated by the `embed.min.js` script when a `conversation_id` is ignored or not recognized, as this could provide further insights into the problem. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/58bb4088-daf1-45d2-9c86-b7eca5b78e5e?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/58bb4088-daf1-45d2-9c86-b7eca5b78e5e?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/58bb4088-daf1-45d2-9c86-b7eca5b78e5e?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/58bb4088-daf1-45d2-9c86-b7eca5b78e5e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/58bb4088-daf1-45d2-9c86-b7eca5b78e5e?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/58bb4088-daf1-45d2-9c86-b7eca5b78e5e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/58bb4088-daf1-45d2-9c86-b7eca5b78e5e?feedback_type=other)</sup>
Author
Owner

@junjiem commented on GitHub (Apr 25, 2025):

Both user_id and conversation_id need to be set and must be correct. And this has not been released in 1.3.0 yet. https://github.com/langgenius/dify/pull/18602

@junjiem commented on GitHub (Apr 25, 2025): Both user_id and conversation_id need to be set and must be correct. And this has not been released in 1.3.0 yet. https://github.com/langgenius/dify/pull/18602
Author
Owner

@ModyQyW commented on GitHub (Apr 25, 2025):

I did some simple investigation.

systemVariables.conversation_id was introduced by https://github.com/langgenius/dify/issues/18602, and dify 1.3.0 does not include this PR.

Furthermore, the logic here might still prioritize using the existing conversation_id instead of the one passed in.

Image

Hope it helps. Thank you! 🙏

@ModyQyW commented on GitHub (Apr 25, 2025): I did some simple investigation. systemVariables.conversation_id was introduced by https://github.com/langgenius/dify/issues/18602, and dify 1.3.0 does not include this PR. Furthermore, the logic here might still prioritize using the existing conversation_id instead of the one passed in. ![Image](https://github.com/user-attachments/assets/e2fa3f77-4a74-4066-be7b-fb38133b5a29) Hope it helps. Thank you! 🙏
Author
Owner

@amarczew commented on GitHub (Apr 25, 2025):

@ModyQyW

Furthermore, the logic here might still prioritize using the existing conversation_id instead of the one passed in.

Is there a recommended way to force the usage of the passed conversation_id?
On my platform, a user can have multiple products, and each product should have its own dedicated chat session. So it's important that I can explicitly load the correct one.

@amarczew commented on GitHub (Apr 25, 2025): @ModyQyW > Furthermore, the logic here might still prioritize using the existing `conversation_id` instead of the one passed in. Is there a recommended way to **force the usage of the passed `conversation_id`**? On my platform, a user can have multiple products, and each product should have its **own dedicated chat session**. So it's important that I can explicitly load the correct one.
Author
Owner

@ModyQyW commented on GitHub (Apr 26, 2025):

Dear @amarczew

In Dify 1.3, users should be able to load the correct conversation they last used.

Currently, I think you can pull the latest code, build the image, and use it to force the usage of the passed conversation_id. I'm out of other ideas at the moment.

@ModyQyW commented on GitHub (Apr 26, 2025): Dear @amarczew In Dify 1.3, users should be able to load the correct conversation they last used. Currently, I think you can pull the latest code, build the image, and use it to force the usage of the passed conversation_id. I'm out of other ideas at the moment.
Author
Owner

@ModyQyW commented on GitHub (Apr 29, 2025):

@amarczew I think this PR is included in v1.3.1. Could you please have a try? Feel free to tell us any issues you are facing.

@ModyQyW commented on GitHub (Apr 29, 2025): @amarczew I think this PR is included in v1.3.1. Could you please have a try? Feel free to tell us any issues you are facing.
Author
Owner

@amarczew commented on GitHub (Apr 29, 2025):

@ModyQyW Which PR are you referring to?

@amarczew commented on GitHub (Apr 29, 2025): @ModyQyW Which PR are you referring to?
Author
Owner

@amarczew commented on GitHub (Apr 29, 2025):

@ModyQyW @junjiem I just tested v1.3.1, and it works exactly as I described in my use case. Thank you both so much for your support!

@amarczew commented on GitHub (Apr 29, 2025): @ModyQyW @junjiem I just tested v1.3.1, and it works exactly as I described in my use case. Thank you both so much for your support!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#13335