T
Typebot10mo ago
T.

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.
4 Replies
Baptiste
Baptiste10mo ago
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
T.
T.10mo ago
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?
Baptiste
Baptiste10mo ago
Sure! Something like this should work:
<button onclick="(() => {Typebot.setPrefilledVariables({...}); Typebot.open()})()">Contact us</button>
<button onclick="(() => {Typebot.setPrefilledVariables({...}); Typebot.open()})()">Contact us</button>
T.
T.10mo ago
Works like a charm! Thank you, @Baptiste
Want results from more Discord servers?
Add your server