baptisteArno / typebot.io

💬 Typebot is a powerful chatbot builder that you can self-host.
https://typebot.io
Other
7.61k stars 2.11k forks source link

Separate Variable Values from Display Text on Button or Picture Choice blocks #1713

Open jwalsh-vori opened 3 months ago

jwalsh-vori commented 3 months ago

When using Buttons or Picture Choice Blocks, the display text is what is stored as the variable value. This makes variable values unwieldy, especially if the display text is long. Also, if a flow is being copied to be localized in another language, any logic that evaluates the variable value has to also be updated to use the localized value.

While it is possible to set the value using a set variable block on each choice, that adds complexity to the flow. It would be idea if we could have an ability to set the variable value for each input choice, so that the display text is what the users selects but the input value is what is stored in a variable. This would ideally be a constant value, so instead of using "Knee Pain" as the value to drive logic, it would use KNEE_PAIN.

See attached images for what this might look like. In the first image, there is a button choice input where a patient chooses which issue they are suffering from. In the 2nd image, I show that for Knee Pain, the health_issue variable value is set to KNEE_PAIN. In the third image, I show how the condition logic evaluates KNEE_PAIN, not "Knee Pain".

This way, when I make a copy of the flow to localize it to another language, only the display text has to change, not the logic.

This could be done as an optional setting perhaps, where the setting of variable value defaults to the display text, unless a value is set at the choice level so that existing flows are not impacted

image

image

image