Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rensheng567 opened this issue Feb 11, 2025 · 2 comments
Labels
question Further information is requested

Comments

@rensheng567
Copy link

rensheng567 commented Feb 11, 2025

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

Copy link

dosubot bot commented Feb 11, 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 dosubot bot added the question Further information is requested label Feb 11, 2025
@rensheng567
Copy link
Author

@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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant