Search
The SparrowDesk Chat Widget allows you to embed live chat support directly into your website or web application.
This guide shows you how to:
Add the following script to your website’s HTML before the closing </body>
tag:
<script src="<https://cdn.sparrowdesk.com/widget.js>" async></script>
This script loads the SparrowDesk chat widget and exposes a global window.sparrowDesk
object that you can use to control and customize the widget.
Opens the chat widget.
window.sparrowDesk.openWidget();
Closes the chat widget.
window.sparrowDesk.closeWidget();
Registers a function to be called when the widget opens.
window.sparrowDesk.onOpen(() => {
console.log("Widget opened");
});
Registers a function to be called when the widget closes.
window.sparrowDesk.onClose(() => {
console.log("Widget closed");
});
Stores tags (e.g., user info or identifiers) for the current session.
window.sparrowDesk.setTags(["vip", "returning-user"]);
Hides both the launcher and the chat canvas.
window.sparrowDesk.hideWidget();
Returns the current widget status: "open"
or "closed"
.
console.log(window.sparrowDesk.status);
Use setConversationFields to pre-fill ticket fields before a conversation starts.
Works with the createMessage
chat API flow.
window.sparrowDesk.setConversationFields({
priority: "med",
status: "todo",
request_type: "Enquiry"
});
priority
, status
Use setContactFields to pre-fill customer profile details before chat starts.
Works with the registerParticipant
chat API flow.
window.sparrowDesk.setContactFields({
full_name: "Jane Doe",
phone: "+15551234567",
gender: "Female",
nick_name: "JD"
});
email
Widget doesn’t appear
window.sparrowDesk
is available before calling methods.Field values not saved
Widget methods not working
Powered By SparrowDesk