DealerAI Chat Javascript API
This document outlines how to programmatically launch the DealerAI chat widget using JavaScript. You can customize the chat behavior based on the customer context, such as providing vehicle information or a conversation hint.
Overview
To trigger the DealerAI chat programmatically, use the following global JavaScript function:
window.DealerAI.api({ action: "send", data: {} });
This function accepts an object with two properties:
action: Currently supports"send"to initiate the chat.data: An object containing optional vehicle and context-related information.
data Object Properties
You can pass the following optional keys within the data object:
| Key | Type | Description |
|---|---|---|
vin | string | Vehicle Identification Number. If provided, the chatbot will display information about the specific vehicle. |
stocknumber | string | Dealership-specific stock number. Similar to vin, the chatbot will use this to present the relevant vehicle details. |
hint | string | Used to guide the chatbot’s greeting message. This helps initiate the conversation in a specific context. Supported values include "test drive", "trade-in", and "sales". |
Note: You may provide either vin or stocknumber. Providing both is allowed, but the system will prioritize the one that is valid or available.
Use Cases
1. Launch Chat Without Vehicle Information
window.DealerAI.api({ action: "send", data: {} });
Behavior:
Opens the DealerAI chat widget and prompts the customer with a general message, such as “How can I assist you today?”.
2. Launch Chat With Vehicle Information
// Using stock number window.DealerAI.api({ action: "send", data: { stocknumber: "U4238A" } }); // Using VIN window.DealerAI.api({ action: "send", data: { vin: "KM8JCDD18SU247344" } });
CopyEdit
Behavior:
The bot will open the chat and present a summary of the specified vehicle, then ask if the customer would like more details.
3. Launch Chat With a Hint (Optional)
window.DealerAI.api({ action: "send",data: {stocknumber: "U4238A",hint: "test drive"}});
Supported hint values:
"test drive""trade-in""sales"
Behavior:
The chatbot will open the chat and tailor the greeting message to the context of the hint. For example, with "test drive", it may ask whether the customer would like to schedule one.
Integration Example
To connect the DealerAI chat to a CTA (Call-To-Action) button on your website, you can use an onclick event as follows:
<a id="cta-button" onclick='window.DealerAI.api({ action: "send", data: { vin: "KM8JCDD18SU247344" } });'> Chat Now </a>