We expose some functions in the Frontend to programmtically control the Chat window.

window.Pylon("show")

Opens the chat window. Useful for programmatically triggering the chat window from an explicit support flow or button on your site.

window.Pylon("hide")

Closes the chat window.

window.Pylon("onChangeUnreadMessagesCount")

Pass in a callback function that is called immediately and when the unread message count changes. If you pass in null as the callback function, the existing callback is removed.

window.Pylon("onChangeUnreadMessagesCount", function (unreadCount) {
  console.log("unread changed!", unreadCount);
});

window.Pylon("setNewIssueCustomFields")

Pass in an object of custom field slugs to their values. New issues created through the chat will have these custom fields values set.

You must first create the corresponding custom fields inside of Pylon.

Example:

window.Pylon("setNewIssueCustomFields", { user_id: "abc123" });

You can find the slug value on the custom fields page next to the custom field.