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, auto-send, and fullscreen control
Alternative method (web component)
You can also use the web component selector:Open chat using web component selector
Parameters
object
Optional configuration object. Can be omitted entirely to simply open the chat without any message. When provided, can contain the following optional properties:
string
The message to send when opening the chat. If omitted, the chat opens without any pre-filled message.
boolean
default:"false"
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.boolean
default:"false"
Whether to open the chat window filling the whole screen on desktop. When
false (default), the chat opens in the normal floating window. On mobile the chat is always fullscreen regardless of
this setting.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 immediatelyopenChat({ fullscreen: true })- Opens chat fullscreen on desktop
Open the launcher in fullscreen by default
Thefullscreen option above controls a single openChat call. To make the launcher (the floating bubble) and every other affordance open the chat fullscreen on desktop by default, set it once at the widget level.
Set it before the widget loads via window.molinSettings:
fullscreen attribute to the embed tag:
openChat({ fullscreen }) always wins over this default, so a specific button can still open the normal floating window. On mobile the chat is always fullscreen regardless of this setting.
Examples
Basic Usage - Open Chat Button
Basic Usage
Pre-filled Message - Product Inquiry
Pre-filled Message
Auto-send Messages - Support Scenarios
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. The recommended approach is to listen for the molin:ready event:
window.Molin already exists: