My Scenario: My conversational CHATFLOW Dify application. The Dify application needs to call HTTP requests to a warehouse management system (WMS) and requires passing the WMS authentication token. My frontend uses an iframe to embed Dify. I hope that when interacting with the Dify application from the frontend, I can automatically pass the WMS authentication token stored in the frontend cookie to the Dify application, so that the Dify application can carry the WMS authentication token when calling HTTP requests to the WMS.
My Current Problem: I’m mainly stuck on how to pass token information to the Dify application. I’m unsure if my frontend passing method is correct, and I also don’t know how the backend Dify application should receive it. What should I do to achieve this? Thanks a lot.
My Current Frontend Code:
I’m trying to pass parameters to the Dify application via the URL (I’m unsure if this passing method is correct)
<CustomDialog
v-model:visible="showIframeDialog"
title="AI助手"
:width="dialogWidth"
>
<iframe
:src="iframeSrc"
style="width: 100%; height: 600px; border: none;"
frameborder="0"
allow="microphone">
</iframe>
</CustomDialog>
const userToken = computed(() => {
return getToken() || '';
});
const iframeSrc = computed(() => {
const token = userToken.value;
window.difyChatbotConfig = {
// 其他配置设置...
inputs: {
token: token,
},
};
// The token here is a temporary test parameter
return `https://udify.app/chatbot/Bcj93xm8UgigIRQj?token="zjh"`;
});
My Dify Application:
I tried to receive it using a hidden field token in the ‘User Input’ node, and also tried to receive it using a session variable token (I’m unsure if this receiving method is correct)
My Debugging Results: In the Dify chat dialog embedded in the frontend iframe, I initiated a conversation. The response first printed the output of the ‘Direct Reply 2’ node I configured in the Dify workflow: ‘Input: Session Variable: System userID: 3446fd41-60eb-4fa7-8d1e-cab16475af1e Passed userID:’. From ‘Input: Session Variable:’, it can be seen that the token obtained by the input node is empty, and the session variable token is also empty. Therefore, I conclude that my code is not connected.

