Share feedback, ideas and get community help

Updated 2 months ago

Specifying `maxlength` on a Text Input block

I have a typebot with a Text Input block that collects text that I later pass into an AI service. I'd like to enforce a max length on this input in order to cap the number of input tokens spent. I see that there's a short text input vs long text input distinction, but I haven't spotted a way to limit the maxlength on the short text input. Is there a way to limit this? Thank you!
B
a
8 comments
You should add a condition block right after the text input to enable any sort of validation.
The goal here is that it is compatible on platform where max-length attribute is not a thing like WhatsApp
But still I guess I could provide that option and validate it automatically for WhatsApp
Thanks! It looks like a Condition block can't operate on the length of text string, so I'm not sure that would work. I also tried using a Script block to truncate the text in the variable, but found that the System.Transcript still included the original user-inputted value (rather than what the Script block modified it to be), so that didn't quite work either.

The solution mentioned in the Github issue sounds good!
Oh thanks for mentioning the conflict with setVariable in Script and Transcript. Most likely a bug
Will take a look into this.
And indeed the workaround for now would be to add a Set variable block Answer length with content: {{Answer}}.length and then have a condition against this particular variable
Add a reply
Sign up and join the conversation on Discord