Overview
TheopenChat
API allows you to programmatically open the chat window and send a message on behalf of the user. This is useful for:
- Sending automated support requests based on user actions
- Creating contextual help buttons that send specific inquiries
- Triggering chat conversations from forms, errors, or page events
- Automating customer service workflows
For controlling widget visibility, see Show/Hide Widget.
Method
The widget exposes this method for opening the chat:Open chat with optional message and auto-send control
Alternative method (web component)
You can also use the web component selector:Open chat using web component selector
Parameters
Optional configuration object. Can be omitted entirely to simply open the chat without any message. When provided, can contain the following optional properties:
The message to send when opening the chat. If omitted, the chat opens without any pre-filled message.
Whether to automatically send the message. When
false
(default), the message will only be prefilled in the input field for the user to review and send manually. When true
, the message is sent
immediately.openChat()
- Opens chat without any messageopenChat({ message: "Hello" })
- Opens chat with pre-filled message (not sent)openChat({ message: "Hello", autoSend: true })
- Opens chat and sends message immediately
Examples
Basic Usage - Open Chat Button
Basic Usage Example
Simple button that opens the chat widgetBasic Usage
Pre-filled Message - Product Inquiry
Pre-filled Message
Auto-send Messages - Support Scenarios
Auto-send Message Example
Quick support buttons that automatically send specific messages:Smart Search with AI Integration
AI Search Integration
The search component integrates AI assistance with product search, allowing users to get personalized recommendations through the chat widget.
Product Grid with AI Expert
Product Grid with AI Expert
The product grid includes an AI expert consultation option that opens the chat widget with a pre-filled message for personalized assistance.
Interactive Playground
Try the openChat API with this interactive example:This playground will only work if the Molin widget is installed on this documentation page. If you’re viewing this in the documentation, it may show a warning that the widget is not loaded.
Technical Note
TheopenChat
method is only available after the widget script has loaded. Always check that the widget is available before calling methods. You can use either approach:
Method 1: Check window.Molin