---
title: "Web Chat"
description: "Add a chat widget to your website with floating widget and JavaScript API."
canonical: "https://docs.cm.com/conversational-ai/web-chat"
---

# Web Chat

> Add a chat widget to your website with floating widget and JavaScript API.

Source: https://docs.cm.com/conversational-ai/web-chat

Add an AI-powered chat widget to your website. Web Chat provides a customizable floating widget with a JavaScript API for deep integration.

## Quick start

Add the widget to any page with a single script tag:

```html
<script
  src="https://webchat.cm.com/widget.js"
  data-account-id="YOUR_ACCOUNT_ID"
  data-bot-id="YOUR_BOT_ID"
  async>
</script>
```

This renders a floating chat button in the bottom-right corner of your page.

## Key capabilities

- **Floating widget** — drop-in chat widget for any website
- **JavaScript API** — programmatic control over chat behavior
- **Presence check** — detect if agents are available for live handover
- **Page push** — proactively suggest pages based on conversation context
- **Event triggers** — fire custom events from chat interactions
- **Shared history** — maintain conversation history across page navigation
- **FAQ integration** — surface knowledge base answers automatically

## JavaScript API

Control the widget programmatically:

```javascript
// Open the chat widget
window.cmWebChat.open();

// Send a message programmatically
window.cmWebChat.sendMessage("I need help with my order");

// Listen for events
window.cmWebChat.on('message', (msg) => {
  console.log('New message:', msg);
});
```
