我是通过页面script方式嵌入集成的,想要在前端传输属性,例如token,在编排流程中读取到,应该怎么做 #58

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

Originally created by @rensheng567 on GitHub (Feb 10, 2025).

我是通过页面script方式嵌入集成的,想要在前端传输属性,例如token,在编排流程中读取到,应该怎么做 #

Originally created by @rensheng567 on GitHub (Feb 10, 2025). 我是通过页面script方式嵌入集成的,想要在前端传输属性,例如token,在编排流程中读取到,应该怎么做 #
yindo added the question label 2026-02-16 11:19:38 -05:00
yindo closed this issue 2026-02-16 11:19:38 -05:00
Author
Owner

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

@rensheng567 你好!我是Dosu,一个可以帮助解决错误、回答问题并成为贡献者的机器人。我会在等待人类维护者的过程中帮助你。

要在前端通过页面脚本嵌入集成的方式传输属性(例如 token),并在编排流程中读取这些属性,可以使用 window.difyChatbotConfig 对象进行配置。以下是实现步骤:

  1. 嵌入脚本:将 Dify 提供的 script 代码嵌入到你的网站的 <head><body> 标签中。

  2. 配置属性:在嵌入的脚本中,使用 window.difyChatbotConfig 对象来传递属性。例如,传递 token 和其他自定义输入:

    window.difyChatbotConfig = {
        token: 'YOUR_TOKEN', // 传递 token
        inputs: {
            // 传递其他属性
            name: 'apple',
        },
    };
    
  3. 读取属性:在编排流程中,Dify 会处理这些输入值。输入值会被 GZIP 压缩并以 base64 编码,然后附加到 URL 上,供后续流程读取。

通过这种方式,你可以在前端传输属性,并在 Dify 的编排流程中读取到这些属性[1][2].

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Feb 10, 2025): <!-- Greeting --> @rensheng567 你好!我是[Dosu](https://dosu.dev),一个可以帮助解决错误、回答问题并成为贡献者的机器人。我会在等待人类维护者的过程中帮助你。 <!-- Answer --> 要在前端通过页面脚本嵌入集成的方式传输属性(例如 token),并在编排流程中读取这些属性,可以使用 `window.difyChatbotConfig` 对象进行配置。以下是实现步骤: 1. **嵌入脚本**:将 Dify 提供的 script 代码嵌入到你的网站的 `<head>` 或 `<body>` 标签中。 2. **配置属性**:在嵌入的脚本中,使用 `window.difyChatbotConfig` 对象来传递属性。例如,传递 token 和其他自定义输入: ```javascript window.difyChatbotConfig = { token: 'YOUR_TOKEN', // 传递 token inputs: { // 传递其他属性 name: 'apple', }, }; ``` 3. **读取属性**:在编排流程中,Dify 会处理这些输入值。输入值会被 GZIP 压缩并以 base64 编码,然后附加到 URL 上,供后续流程读取。 通过这种方式,你可以在前端传输属性,并在 Dify 的编排流程中读取到这些属性<sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/application-publishing/embedding-in-websites.md)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/workflow/node/start.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/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=other)</sup>
Author
Owner

@rensheng567 commented on GitHub (Feb 10, 2025):

@rensheng567 你好!我是Dosu,一个可以帮助解决错误、回答问题并成为贡献者的机器人。我会在等待人类维护者的过程中帮助你。

要在前端通过页面脚本嵌入集成的方式传输属性(例如 token),并在编排流程中读取这些属性,可以使用 window.difyChatbotConfig 对象进行配置。以下是实现步骤:

  1. 嵌入脚本:将 Dify 提供的 script 代码嵌入到你的网站的 <head><body> 标签中。
  2. 配置属性:在嵌入的脚本中,使用 window.difyChatbotConfig 对象来传递属性。例如,传递 token 和其他自定义输入:
    window.difyChatbotConfig = {
    token: 'YOUR_TOKEN', // 传递 token
    inputs: {
    // 传递其他属性
    name: 'apple',
    },
    };
  3. 读取属性:在编排流程中,Dify 会处理这些输入值。输入值会被 GZIP 压缩并以 base64 编码,然后附加到 URL 上,供后续流程读取。

通过这种方式,你可以在前端传输属性,并在 Dify 的编排流程中读取到这些属性[1][2].

To continue talking to Dosu, mention @dosu.

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

怎么在流程编排中读取,请给出示例

@rensheng567 commented on GitHub (Feb 10, 2025): > [@rensheng567](https://github.com/rensheng567) 你好!我是[Dosu](https://dosu.dev),一个可以帮助解决错误、回答问题并成为贡献者的机器人。我会在等待人类维护者的过程中帮助你。 > > 要在前端通过页面脚本嵌入集成的方式传输属性(例如 token),并在编排流程中读取这些属性,可以使用 `window.difyChatbotConfig` 对象进行配置。以下是实现步骤: > > 1. **嵌入脚本**:将 Dify 提供的 script 代码嵌入到你的网站的 `<head>` 或 `<body>` 标签中。 > 2. **配置属性**:在嵌入的脚本中,使用 `window.difyChatbotConfig` 对象来传递属性。例如,传递 token 和其他自定义输入: > window.difyChatbotConfig = { > token: 'YOUR_TOKEN', // 传递 token > inputs: { > // 传递其他属性 > name: 'apple', > }, > }; > 3. **读取属性**:在编排流程中,Dify 会处理这些输入值。输入值会被 GZIP 压缩并以 base64 编码,然后附加到 URL 上,供后续流程读取。 > > 通过这种方式,你可以在前端传输属性,并在 Dify 的编排流程中读取到这些属性[[1]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/application-publishing/embedding-in-websites.md)[[2]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/workflow/node/start.md). > > _To continue talking to [Dosu](https://dosu.dev), mention [@dosu](https://github.com/dosu)._ > > Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/bbb4edc8-9017-4e00-ab1d-8dc68c258015?feedback_type=other) 怎么在流程编排中读取,请给出示例
Author
Owner

@xiaobai1990zhan commented on GitHub (Feb 25, 2025):

chatflow工作流中的节点如何能读取到这些属性

@xiaobai1990zhan commented on GitHub (Feb 25, 2025): chatflow工作流中的节点如何能读取到这些属性
Author
Owner

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

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

@Kingyumu commented on GitHub (Mar 3, 2025): 你好,你解决了吗?我也遇到了和你一样的问题
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-docs-archived#58