How to Launch a chat with a button | Community
Skip to main content
Answered

How to Launch a chat with a button

  • February 23, 2022
  • 3 replies
  • 216 views

Hello,

Is there a good way to launch a popup chat with a button - this is what I mean: 

https://www.loom.com/share/d158a0287e5b4c11b1aa7393331df2f2

 

Best answer by mathio-tf

In your share page you can get embed snippet for popup:

Then add data-tf-chat to your embed code like this (part of the code truncated):

<button data-tf-chat data-tf-popup="<form-id>" ...>Launch me</button>
<script src="//embed.typeform.com/next/embed.js"></script>

 

 

If you want to build your own button from scratch you can use our Embed SDK. If you want full control over your embed you can build it in JavaScript. The code would look something like this:

<button id="my-awesome-button" class="my-awesome-class">open form</button>
<script src="//embed.typeform.com/next/embed.js"></script>
<link rel="stylesheet" href="//embed.typeform.com/next/css/popup.css" />
<script>
  const { toggle } = window.tf.createPopup('<form-id>')
  document.querySelector('#my-awesome-button').onclick = toggle
</script>

 

View original

3 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14921 replies
  • February 24, 2022

Hi @AdamMktgTy Welcome to the community! You would need to use some custom code to do this, but @mathio or @picsoung might have an example of this for you!


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • Answer
  • February 24, 2022

In your share page you can get embed snippet for popup:

Then add data-tf-chat to your embed code like this (part of the code truncated):

<button data-tf-chat data-tf-popup="<form-id>" ...>Launch me</button>
<script src="//embed.typeform.com/next/embed.js"></script>

 

 

If you want to build your own button from scratch you can use our Embed SDK. If you want full control over your embed you can build it in JavaScript. The code would look something like this:

<button id="my-awesome-button" class="my-awesome-class">open form</button>
<script src="//embed.typeform.com/next/embed.js"></script>
<link rel="stylesheet" href="//embed.typeform.com/next/css/popup.css" />
<script>
  const { toggle } = window.tf.createPopup('<form-id>')
  document.querySelector('#my-awesome-button').onclick = toggle
</script>

 


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14921 replies
  • March 1, 2022

@AdamMktgTy let us know if @mathio ‘s solution worked for you!


Reply