dify 网站嵌入 如何传入非 inputs的 数据,不希望能在前端展示。希望能赋值给环境变量或者会话变量。 #67

Closed
opened 2026-02-16 11:19:39 -05:00 by yindo · 6 comments
Owner

Originally created by @dalaosheng on GitHub (Feb 20, 2025).

Originally created by @dalaosheng on GitHub (Feb 20, 2025).
yindo added the enhancement label 2026-02-16 11:19:39 -05:00
yindo closed this issue 2026-02-16 11:19:39 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 20, 2025):

@dalaosheng 你好!我是一个可以帮助您解决错误、回答问题并成为贡献者的机器人。在等待人类维护者时,我可以为您提供帮助。

在 Dify 中,可以通过环境变量和会话变量来传递不希望在前端展示的数据。

  1. 环境变量:这些变量用于保护敏感信息,如 API 密钥和数据库密码。它们存储在工作流中,而不是代码中,可以在大多数节点中全局引用。环境变量通常是只读的,不能在前端直接访问。

  2. 会话变量:在 Chatflow 应用中使用会话变量,可以在同一会话中临时存储特定信息。这些变量支持多种数据类型,如字符串、数字、对象和数组,并且可以在会话中读写。

通过这些机制,您可以确保敏感数据在前端不被暴露 [1][2][3].

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 (Feb 20, 2025): <!-- Greeting --> @dalaosheng 你好!我是一个可以帮助您解决错误、回答问题并成为贡献者的机器人。在等待人类维护者时,我可以为您提供帮助。 <!-- Answer --> 在 Dify 中,可以通过环境变量和会话变量来传递不希望在前端展示的数据。 1. **环境变量**:这些变量用于保护敏感信息,如 API 密钥和数据库密码。它们存储在工作流中,而不是代码中,可以在大多数节点中全局引用。环境变量通常是只读的,不能在前端直接访问。 2. **会话变量**:在 Chatflow 应用中使用会话变量,可以在同一会话中临时存储特定信息。这些变量支持多种数据类型,如字符串、数字、对象和数组,并且可以在会话中读写。 通过这些机制,您可以确保敏感数据在前端不被暴露 <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/llms.txt)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/jp/getting-started/install-self-hosted/environments.md)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/getting-started/install-self-hosted/environments.md)</sup>. <!-- 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/a3af6a2d-b6d7-4658-a6a1-da0ab535896a?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/a3af6a2d-b6d7-4658-a6a1-da0ab535896a?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/a3af6a2d-b6d7-4658-a6a1-da0ab535896a?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/a3af6a2d-b6d7-4658-a6a1-da0ab535896a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a3af6a2d-b6d7-4658-a6a1-da0ab535896a?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/a3af6a2d-b6d7-4658-a6a1-da0ab535896a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a3af6a2d-b6d7-4658-a6a1-da0ab535896a?feedback_type=other)</sup>
Author
Owner

@dalaosheng commented on GitHub (Feb 20, 2025):

我是希望通过网站嵌入的方式。
window.difyChatbotConfig={
inputs:{
}
}

该办法只能改变输入的参数,我希望改变的是环境变量或者会话变量的参数。

@dalaosheng commented on GitHub (Feb 20, 2025): 我是希望通过网站嵌入的方式。 window.difyChatbotConfig={ inputs:{ } } 该办法只能改变输入的参数,我希望改变的是环境变量或者会话变量的参数。
Author
Owner

@dosubot[bot] commented on GitHub (Feb 20, 2025):

在 Dify 的网站嵌入中,window.difyChatbotConfiginputs 参数用于传递输入数据,但如果你希望修改环境变量或会话变量,直接通过前端配置可能不够。

对于会话变量,Dify 提供了 chat-messages API 端点,可以在会话中动态管理变量。你可以通过 API 调用来设置或修改会话变量,而不是通过前端的 window.difyChatbotConfig。这需要在后端进行 API 调用,以确保安全性,避免在前端暴露敏感信息 [1]

环境变量通常用于存储敏感信息,如 API 密钥,通常在后端配置,不能通过前端直接修改。确保这些变量的安全性和隐私性是关键。

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 (Feb 20, 2025): <!-- Answer --> 在 Dify 的网站嵌入中,`window.difyChatbotConfig` 的 `inputs` 参数用于传递输入数据,但如果你希望修改环境变量或会话变量,直接通过前端配置可能不够。 对于会话变量,Dify 提供了 `chat-messages` API 端点,可以在会话中动态管理变量。你可以通过 API 调用来设置或修改会话变量,而不是通过前端的 `window.difyChatbotConfig`。这需要在后端进行 API 调用,以确保安全性,避免在前端暴露敏感信息 <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/application-publishing/developing-with-apis.md)</sup>。 环境变量通常用于存储敏感信息,如 API 密钥,通常在后端配置,不能通过前端直接修改。确保这些变量的安全性和隐私性是关键。 <!-- 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/a1fa5ccd-82ef-4f9b-85a0-8fc02c6d2d5e?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/a1fa5ccd-82ef-4f9b-85a0-8fc02c6d2d5e?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/a1fa5ccd-82ef-4f9b-85a0-8fc02c6d2d5e?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/a1fa5ccd-82ef-4f9b-85a0-8fc02c6d2d5e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a1fa5ccd-82ef-4f9b-85a0-8fc02c6d2d5e?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/a1fa5ccd-82ef-4f9b-85a0-8fc02c6d2d5e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a1fa5ccd-82ef-4f9b-85a0-8fc02c6d2d5e?feedback_type=other)</sup>
Author
Owner

@dalaosheng commented on GitHub (Feb 20, 2025):

如何通过 API 调用来修改 chatflow 或者 workflow 的环境变量

@dalaosheng commented on GitHub (Feb 20, 2025): 如何通过 API 调用来修改 chatflow 或者 workflow 的环境变量
Author
Owner

@Kingyumu commented on GitHub (Mar 3, 2025):

你解决了吗,我也遇到了和你一样的问题

@Kingyumu commented on GitHub (Mar 3, 2025): 你解决了吗,我也遇到了和你一样的问题
Author
Owner

@gdamao commented on GitHub (Mar 6, 2025):

网站嵌入时,我们希望跟网站的数据有一些交互,自动设置会话变量,不需要让用户输入input,该怎么处理? https://github.com/langgenius/dify/issues/14899 使用隐藏的input变量

@gdamao commented on GitHub (Mar 6, 2025): 网站嵌入时,我们希望跟网站的数据有一些交互,自动设置会话变量,不需要让用户输入input,该怎么处理? https://github.com/langgenius/dify/issues/14899 使用隐藏的input变量
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-docs-archived#67