How to Embed Chat on Website Pages in a Custom Location

Updated 2 min read

The txt.me chat widget usually appears in the bottom-right corner, but you may want it to show within a specific section of your site. Learn how to embed chat on website pages, support sections, knowledge bases, or popups by adding a target HTML element and adjusting the widget code.

By default, the txt.me chatbox shows up on your website as a widget in the bottom-right corner.
In this guide, we will show how with minimum coding you can make rendering in an <div> anywhere on your website. It might be helpful if you decided to integrate the live chat on your support page, knowledge base, popup window, or in any special section.

Embed Chat on Website Pages

Here the chat box is shown right in the middle of the blog post. This is a real live chat with our customer service agents. Feel free to ask us any questions.

ChatBox HTML Source Code

Here is the code that made it happen, install it in the section of your website:

<script type="text/javascript">
      window.txtmeData = {
          settings: {
            chatToDiv: '#exampleDivId'
          },
      };               
      
      (function (w,d,c,i) {
          w[c]=w[c]||[];
          var n = d.getElementsByTagName('script')[0],
              s = d.createElement('script');
          s.src = 'https://v2.txt.me/livechat/js/wrapper/' + i;
          s.type = 'text/javascript';
          s.async = true;
          n.parentNode.insertBefore(s, n);
      })(window,document,'txtmeData','000000000000000000000000000000');
</script>

The HTML code for the <div> where the chat box has shown up looks like this:

<div id="exampleDivId" style="width: 300px; height: 500px; margin:auto;box-shadow: rgba(164, 164, 164, 0.49) 0px 2px 24px;">
</div>

To finish the installation replace the exampleDivId with the id of the HTML element you want the widget to render to and replace the 000000000000000000000000000000 with the id number of your widget.

You can take it from the default HTML chat box code in your txt.me dashboard, which looks like this:

<!-- Start of txt.me widget code -->
<script src="https://v3.txt.me/livechat/js/wrapper/cfa2f53fca55424686ea224b03a2aa79" async></script>
<noscript><a href="https://txt.me/reviews/cfa2f53fca55424686ea224b03a2aa99" rel="nofollow">Rate customer support</a>, powered by <a href="https://txt.me" rel="noopener nofollow" target="_blank">txt.me</a></noscript>
<!-- End of txt.me widget code -->

Put an AI agent and a real person on your website chat

Start free with one agent and unlimited chats. Add the AI agent, WhatsApp, email and Human Backup operators when you need them.