Adding Quack AI to your website

Adding the Quack AI SDK to your website is just a few simple steps.

Step 1

Add the following single line of code to your HTML.

<script>
(function(q,u,a,c,k,i,o){
      q[a] = q[a] || function () { (q[a].q = q[a].q || 
	    []).push(arguments) };
      i=u.createElement(c);
      i.async=1;
      i.id = 'quack-license'
      i.src="https://sdk.thequack.ai/p/verify.min.js"
      // for eu use following:
      // i.src="https://sdk.thequack.ai/eu/verify.min.js"
      i.setAttribute(a,k)
      o=u.getElementsByTagName(c)[0];
      o.parentNode.insertBefore(i,o);
   })(window, document, "quack", "script", <YOUR_TOKEN>);
</script>

This script tag will load the Javascript required to render the widget.

Step 2 (optional)

To identify a user, call this function when you obtain the user’s id or email. If the user is meant to stay anonymous, there’s no need to call this function.

window["quack"].identify({
	email: 'your user email',
	id: 'your user id in your app',
	...props // whatever you want to pass
})

That's it! See below for some examples. Note that this is to identify the user on the frontend so that conversation history is preserved.

It's highly recommended to make the User ID an unique unguessable value (like an UUID).

Step 3 - If Chat is enabled (optional)

// to show the chat widget
window["quack"].showChat() 

// to hide the chat widget
window["quack"].hideChat()

Last updated