megadeskSendText
A global function available on the window object that programmatically sends a message to the Megadesk chatbot widget.
Signature
window.megadeskSendText(message: string)
Parameters
| Parameter | Type | Description |
|---|---|---|
message | string | The text message to send to the chatbot |
Usage
This API is useful for triggering the chatbot with pre-defined messages based on user actions, such as clicking buttons or links throughout your site.
Example
// Open chatbot with a product inquiry
document.getElementById("pricing-btn").addEventListener("click", () => {
window.megadeskSendText("Tell me about your pricing plans.");
});
// Or in a React component
<button onClick={() => window.megadeskSendText("How do I get started?")}>
Get Started
</button>
Notes
- The function is attached to the global
windowobject, so it's accessible from anywhere in your client-side code - Call it after the Megadesk widget script has loaded
- Useful for creating contextual entry points to support (e.g., triggering specific help topics from relevant pages)
