mirror of
https://github.com/langgenius/dify-docs.git
synced 2026-07-22 04:15:24 -04:00
[DOCS]: If I want to add user_id in the first embedding method, iframe, how can I implement it? Currently, it can only be added through script #231
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lilibo217 on GitHub (Aug 20, 2025).
Type of Documentation Change
Content update
Documentation Page URL or Path
No response
Current Content
If I want to add user_id in the first embedding method, iframe, how can I implement it? Currently, it can only be added through script
Suggested Changes
If I want to add user_id in the first embedding method, iframe, how can I implement it? Currently, it can only be added through script
Reason for Change
If I want to add user_id in the first embedding method, iframe, how can I implement it? Currently, it can only be added through script
Code of Conduct
@dosubot[bot] commented on GitHub (Aug 20, 2025):
Hi @lilibo217! I'm Dosu and I’m helping the dify-docs team.
You can pass user_id in the iframe embedding method by appending it as a URL parameter, but it must be GZIP-compressed, Base64-encoded, and then URI-encoded. For example, to pass user_id with value apple, compress and encode it, then use a URL like:
Replace the value after user_id= with your own encoded string. The official docs describe this process for all input parameters, including user_id. Script embedding allows you to set user_id directly in the config, but for iframe embedding, you must use the URL parameter method as described above (docs reference).
If you experienced issues with user_id in iframe embedding, make sure you are using Dify version 1.7.2 or later, as earlier versions had known bugs with this feature (issue reference).
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

@lilibo217 commented on GitHub (Aug 20, 2025):
Thank you very much for your reply. I have tried my way as you said. Here is my code. Perhaps my expression was not clear enough. I wanted to add user_id in the first embedding method iframe, and the effect is similar to the systemVariables: {user_i: '******'} embedded in the second bubble button. Passing different user_ids can recognize different users' historical conversations, but I found that changing this doesn't work. I don't know if my method was written incorrectly or if there is a problem with passing parameters. I sincerely request a reply. Thank you again。
------------------ 原始邮件 ------------------
发件人: "langgenius/dify-docs" @.>;
发送时间: 2025年8月20日(星期三) 下午2:46
@.>;
@.@.>;
主题: Re: [langgenius/dify-docs] [DOCS]: If I want to add user_id in the first embedding method, iframe, how can I implement it? Currently, it can only be added through script (Issue #422)
dosubot[bot] left a comment (langgenius/dify-docs#422)
Hi @lilibo217! I'm Dosu and I’m helping the dify-docs team.
You can pass user_id in the iframe embedding method by appending it as a URL parameter, but it must be GZIP-compressed, Base64-encoded, and then URI-encoded. For example, to pass user_id with value apple, compress and encode it, then use a URL like:
@dosubot[bot] commented on GitHub (Aug 20, 2025):
The main issue is the parameter name: for Dify iframe embedding to recognize user_id and map historical conversations correctly, you must pass it as
sys.user_id(not justuser_id) in the URL, and it must be GZIP-compressed, Base64-encoded, and URI-encoded see code reference see docs.Here's how to fix your code:
This will allow Dify to distinguish users and load their respective conversation histories via iframe embedding see implementation details.
Make sure you're running Dify v1.7.2 or later, as earlier versions had bugs with user_id in iframe embedding see bug fix.
If it still doesn't work, check for browser console errors, verify your encoding, and clear browser cache/local storage. Known limitations: session resets may clear user mapping, and switching users rapidly can cause persistence issues (being actively improved).
Let me know if you need more troubleshooting!
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

@killerddd3 commented on GitHub (Jan 4, 2026):
great