How to customize your Webchat using snippet code

How to customize your Webchat using snippet code

Learn webchat customizations using snippet code and get a detailed look at our Tactful AI chat SDK beta program.
Last Updated June 15, 2022
Table of Contents

We will show you how to customize your webchat using snippet code in this article.

So let’s dive into it!

This is a snippet code example that will guide you how to insert new custom code for different actions:

<div id="embedded_messenger">
              <div id="widget-launcher"></div>
              <iframe id="tactful_client" src=""></iframe>
            <script src=""></script>
            <link rel="stylesheet" href="" />
                var profile = <your profile name>;
                var token = xxxxxxxxxxxxxxxxxxxxxxx;
                var channelId = xxx;
                <! –– insert your custom code here ––>
                Tactful.start({ profile: profile, token: token, channelId: channelId });

Below are some possible code customizations:

  • Make your bot start with greeting customers! To call the restart intent, insert this line of code: 
    Action = ‘Restart’;
  • Want to speak to the bot? Enable voice in chat by writing:
    voiceMode = true;
  • To disable voice in chat: voiceMode = false;
  • Some webchats automatically open once users log into the website. To make the widget closed by default, add this custom code:
    closeWebchat = true;
  • To enable the “close” button to close webchat in mobile, insert this line of code:
    closeButton = true;
  • Want the bot to automatically list your products menu? To browse, use this code:
  • If you already have your customer’s info, make their lives easier and pass it to the bot, so that it doesn’t ask for this info again. To check data of the user who logged in your website add this line of code:
    User = {name: ‘x’, email: ‘y’, first_name: '', last_name: '', phone_number: };

Still, you can generally edit your messages “e.g. welcome message.” from the language editor.

Want to learn more?
Was this article helpful?