ChatFlow

Chatbot Embed Script

Chatbot Embed Script refers to a piece of code that you can add to your website to integrate a chatbot. This script allows the chatbot to appear on your site and interact with your visitors, providing automated support and information.
Back to Glossary

Chatbot Embed Script

A Chatbot Embed Script is a code snippet that you add to your website to integrate a chatbot. This allows the chatbot to appear on your site and interact with visitors, providing automated support and information. There are different methods to embed a chatbot, each with its own way of working and communicating.

Types of Chatbot Embed Scripts

  1. Web Component Injection: This method involves adding a custom element to your webpage. The script inserts a web component tag into your site's HTML, which then loads the chatbot interface. Communication is typically event-based, where the component reacts to user interactions.
  2. iFrame Integration: An iFrame lets you embed another HTML page within your webpage. The chatbot interface is hosted separately and displayed within an iFrame on your site. Communication usually happens through the postMessage API, which allows secure messaging between the iFrame and the host page.
  3. JavaScript Snippet: This is a simple JavaScript code that you embed in your site's HTML. The script fetches the chatbot's code from a server and integrates it into your webpage. Communication methods can include polling (regularly checking for updates) or WebSockets (for real-time interaction).

Communication Methods

  • Polling: The chatbot regularly checks the server for new messages or updates. It's simple but may not be as fast as other methods.
  • WebSockets: Allows real-time, two-way communication between the browser and server. This method provides instant updates and a smoother user experience.
  • Event-Based Communication: Uses JavaScript events to facilitate communication between the chatbot and the webpage. It's efficient for handling user interactions and integrating with other web components.