Share feedback, ideas and get community help

Updated last year

PrefilledVariables in buttons

Hi Typebot family.

I added a Typebot bubble to my website. Works great, but now I want to add a separate button with a variable prefilled.

How do I prefill a variable in the button below?

<button onclick="Typebot.open()">Contact us</button>

Full code please, I'm a noob.
B
T
4 comments
Have you checked the prefilledVariables option?

https://docs.typebot.io/embed/html-javascript#additional-configuration

You'd just have to add it to your init code
I did, @Baptiste. For prefilling variables to URL and embedding code, it's clear. But I want to have different buttons on my websites that open the same Typebot. And each button automatically fills in different variables. Is there a way to do it?
Sure! Something like this should work:

Plain Text
<button onclick="(() => {Typebot.setPrefilledVariables({...}); Typebot.open()})()">Contact us</button>
Works like a charm!
Thank you, @Baptiste
Add a reply
Sign up and join the conversation on Discord