Template Issues: How to Determine Which Button is Clicked in Chatflow? #12118

Closed
opened 2026-02-21 19:05:52 -05:00 by yindo · 4 comments
Owner

Originally created by @jason-lee-x on GitHub (Mar 25, 2025).

Originally assigned to: @crazywoola on GitHub.

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

Template Issues: How to Determine Which Button is Clicked in Chatflow?

Description
In my Chatflow, I use an agent to call an API.
Before AI actually executes the request, I need users to confirm that they have granted permission.

To achieve this, I use a template to create an interactive panel with two buttons: Yes and No.
The question is: How can I let the AI know which button has been clicked?

Code Snippet

<form data-format="json">
    <button type="submit" value="1" data-size="small" data-variant="primary">Yes</button>
    <button type="submit" value="0" data-size="small" data-variant="primary">No</button>
</form>

Expected Behavior

  • When the user clicks Yes, AI should recognize and proceed with calling the API.
  • When the user clicks No, AI should recognize and abort the request.

Actual Behavior

  • AI does not seem to recognize which button was clicked.

Question

How should I properly capture the clicked button’s value and pass it to AI?


Embedded Issues: How to Retrieve JWT from URL in Chatflow?

Description

I have embedded Dify into my website using JavaScript.
In difyChatbotConfig, I have set the inputs parameter to pass the user's JWT.

However, I need to retrieve the JWT parameter from the URL within Chatflow.

Question

How can I access the JWT parameter from the URL inside Chatflow?

Originally created by @jason-lee-x on GitHub (Mar 25, 2025). Originally assigned to: @crazywoola on GitHub. ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Provide a description of requested docs changes Template Issues: How to Determine Which Button is Clicked in Chatflow? Description In my Chatflow, I use an agent to call an API. Before AI actually executes the request, I need users to confirm that they have granted permission. To achieve this, I use a **template** to create an interactive panel with two buttons: **Yes** and **No**. The question is: **How can I let the AI know which button has been clicked?** Code Snippet ```html <form data-format="json"> <button type="submit" value="1" data-size="small" data-variant="primary">Yes</button> <button type="submit" value="0" data-size="small" data-variant="primary">No</button> </form> ``` ### Expected Behavior - When the user clicks **Yes**, AI should recognize and proceed with calling the API. - When the user clicks **No**, AI should recognize and abort the request. ### Actual Behavior - AI does not seem to recognize which button was clicked. ### Question How should I properly capture the clicked button’s value and pass it to AI? --- ## Embedded Issues: How to Retrieve JWT from URL in Chatflow? ### Description I have embedded **Dify** into my website using JavaScript. In **difyChatbotConfig**, I have set the `inputs` parameter to pass the user's **JWT**. However, I need to retrieve the JWT parameter from the **URL** within Chatflow. ### Question How can I access the **JWT** parameter from the URL inside Chatflow?
yindo added the 🙋‍♂️ question label 2026-02-21 19:05:52 -05:00
yindo closed this issue 2026-02-21 19:05:52 -05:00
Author
Owner

@crazywoola commented on GitHub (Mar 25, 2025):

Feat/14573 support more types in form (#15093)

Q1: I suggest using the checkbox instead.
And you don't need to wrap the buttons in the form. See this PR feat: support button in markdown (#9876)

<button data-message="yes" data-variant="primary">Yes</button>
<button data-message="no" data-variant="warning">No</button>

You can define the buttons like above. Buttons within the forms will have different behavior.
Also, you can use it as suggested questions as well.

Q2 How can I access the JWT parameter from the URL inside Chatflow?

Not supported yet.

@crazywoola commented on GitHub (Mar 25, 2025): Feat/14573 support more types in form (#15093) Q1: I suggest using the checkbox instead. And you don't need to wrap the buttons in the form. See this PR feat: support button in markdown (#9876) ``` <button data-message="yes" data-variant="primary">Yes</button> <button data-message="no" data-variant="warning">No</button> ``` You can define the buttons like above. Buttons within the forms will have different behavior. Also, you can use it as suggested questions as well. Q2 How can I access the JWT parameter from the URL inside Chatflow? Not supported yet.
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2025):

@JasonLeeForOnly Hello! I'm here to help you with any bugs, questions, or contributions you might have.

To determine which button is clicked in your Chatflow, you can capture the button's value using the handleSend function. When a button is clicked, its value can be included in the form data sent to the AI agent. Here's how you can modify your form to ensure the clicked button's value is captured:

  1. Modify the Form Submission: Ensure that the form submission captures the button's value. You can achieve this by adding a name attribute to your buttons. This way, when the form is submitted, the button's value is included in the form data.
<form data-format="json">
    <button type="submit" name="user_confirmation" value="1" data-size="small" data-variant="primary">Yes</button>
    <button type="submit" name="user_confirmation" value="0" data-size="small" data-variant="primary">No</button>
</form>
  1. Handle the Form Data: In your handleSend function, ensure that the form data is processed to include the button's value. This value can then be used to determine the next steps in your Chatflow logic.

Regarding retrieving the JWT from the URL in Chatflow, you would typically access URL parameters using JavaScript. However, the specific mechanism for accessing URL parameters within the Chatflow environment wasn't found in the available documentation. You might need to use JavaScript to parse the URL and extract the JWT parameter, then pass it to the Chatflow through the inputs parameter in difyChatbotConfig.

If you have further questions or need more detailed guidance, feel free to ask!

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 (Mar 25, 2025): <!-- Greeting --> @JasonLeeForOnly Hello! I'm here to help you with any bugs, questions, or contributions you might have. <!-- Answer --> To determine which button is clicked in your Chatflow, you can capture the button's value using the `handleSend` function. When a button is clicked, its value can be included in the form data sent to the AI agent. Here's how you can modify your form to ensure the clicked button's value is captured: 1. **Modify the Form Submission**: Ensure that the form submission captures the button's value. You can achieve this by adding a `name` attribute to your buttons. This way, when the form is submitted, the button's value is included in the form data. ```html <form data-format="json"> <button type="submit" name="user_confirmation" value="1" data-size="small" data-variant="primary">Yes</button> <button type="submit" name="user_confirmation" value="0" data-size="small" data-variant="primary">No</button> </form> ``` 2. **Handle the Form Data**: In your `handleSend` function, ensure that the form data is processed to include the button's value. This value can then be used to determine the next steps in your Chatflow logic. Regarding retrieving the JWT from the URL in Chatflow, you would typically access URL parameters using JavaScript. However, the specific mechanism for accessing URL parameters within the Chatflow environment wasn't found in the available documentation. You might need to use JavaScript to parse the URL and extract the JWT parameter, then pass it to the Chatflow through the `inputs` parameter in `difyChatbotConfig`. If you have further questions or need more detailed guidance, feel free to ask! <!-- 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/769abf8d-b7f1-46aa-adc6-63af78a54775?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/769abf8d-b7f1-46aa-adc6-63af78a54775?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/769abf8d-b7f1-46aa-adc6-63af78a54775?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/769abf8d-b7f1-46aa-adc6-63af78a54775?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/769abf8d-b7f1-46aa-adc6-63af78a54775?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/769abf8d-b7f1-46aa-adc6-63af78a54775?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/769abf8d-b7f1-46aa-adc6-63af78a54775?feedback_type=other)</sup>
Author
Owner

@jason-lee-x commented on GitHub (Mar 25, 2025):

Feat/14573 support more types in form (#15093)

Q1: I suggest using the checkbox instead.
And you don't need to wrap the buttons in the form. See this PR feat: support button in markdown (#9876)

<button data-message="yes" data-variant="primary">Yes</button>
<button data-message="no" data-variant="warning">No</button>

You can define the buttons like above. Buttons within the forms will have different behavior.
Also, you can use it as suggested questions as well.

Q2 How can I access the JWT parameter from the URL inside Chatflow?

Not supported yet.

I truly appreciate your response.
With your insightful advice, I’m confident Q1 can be addressed effortlessly.

For Q2, does the team have a strategy to accomplish it, or is there another way to manage authentication? Specifically, how can I securely pass a JWT token through my site to Dify, ensuring my agent calls the API with the user’s token?

@jason-lee-x commented on GitHub (Mar 25, 2025): > Feat/14573 support more types in form (#15093) > > Q1: I suggest using the checkbox instead. > And you don't need to wrap the buttons in the form. See this PR feat: support button in markdown (#9876) > > > > ``` > <button data-message="yes" data-variant="primary">Yes</button> > <button data-message="no" data-variant="warning">No</button> > ``` > > You can define the buttons like above. Buttons within the forms will have different behavior. > Also, you can use it as suggested questions as well. > > Q2 How can I access the JWT parameter from the URL inside Chatflow? > > Not supported yet. I truly appreciate your response. With your insightful advice, I’m confident Q1 can be addressed effortlessly. For Q2, does the team have a strategy to accomplish it, or is there another way to manage authentication? Specifically, how can I securely pass a JWT token through my site to Dify, ensuring my agent calls the API with the user’s token?
Author
Owner

@crazywoola commented on GitHub (Mar 25, 2025):

See https://github.com/langgenius/dify/pull/16062

We are also trying different ways to get user's credentials as well.

@crazywoola commented on GitHub (Mar 25, 2025): See https://github.com/langgenius/dify/pull/16062 We are also trying different ways to get user's credentials as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12118