JavaScript API
Available API methods to programmatically interface with the chat
We expose some functions in the Frontend to programmtically control the Chat window.
window.Pylon("show")
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")
window.Pylon("hide")
Closes the chat window.
window.Pylon("onShow")
window.Pylon("onShow")
Pass in a callback function that is called when the chat is shown. Useful for managing state of the chat window. If you pass in null
as the callback function, the existing callback is removed.
window.Pylon("onHide")
window.Pylon("onHide")
Pass in a callback function that is called when the chat is hidden. Useful for managing state of the chat window. If you pass in null
as the callback function, the existing callback is removed.
window.Pylon("hideChatBubble")
window.Pylon("hideChatBubble")
Hides the chat bubble. Useful for hiding it in situations where it’s inappropriate or it’s blocking something underneath (ie an open modal). Does not override the “Default Hide Chat Bubble” setting on the settings page.
window.Pylon("showChatBubble")
window.Pylon("showChatBubble")
Shows the chat bubble. Useful for hiding it in situations where it’s inappropriate or it’s blocking something underneath (ie an open modal). Does not override the “Default Hide Chat Bubble” setting on the settings page.
window.Pylon("onChangeUnreadMessagesCount")
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("setNewIssueCustomFields")
window.Pylon("setNewIssueCustomFields")
Pass in an object of custom field slugs to their values. New issues created through in-app chat messaging will have these custom fields values set.
You must first create the corresponding custom fields inside of Pylon.
Example:
You can find the slug value on the custom fields page next to the custom field.
window.Pylon("setTicketFormFields")
window.Pylon("setTicketFormFields")
Pass in an object field slugs to their values. Ticket forms in the in-app chat widget will have these values set as default values.
Note that the passed object will apply to all ticket forms. Superfluous and/or invalid fields will be ignored.
Example:
You can find the slug value on the custom fields page next to the custom field.
window.Pylon("showNewMessage", "string")
window.Pylon("showNewMessage", "string")
Pass in a message to prepopulate in the editor. For example, use this when a user runs into an error in your application and you want to prefill a message they can submit.
Optionally, this string can also be HTML. For example, for rendering a link. Pass an optional argument indicating the message to be shown is HTML.
NOTE: Only specific HTML tags are supported: <a>
, <b>
, <p>
, and <i>
. If other tags are used, the editor may error.
window.Pylon("showTicketForm", "string")
window.Pylon("showTicketForm", "string")
Navigates the chat bubble to a specified ticket form, by ticket form slug.
The ticket form slug can be found in the edit ticket form page under Slug.
window.Pylon("showKnowledgeBaseArticle", "string")
window.Pylon("showKnowledgeBaseArticle", "string")
Navigates the chat bubble to a specified knowledge base article, by article ID.
The article ID can be found in the URL of the public view of a knowledge base article, as the first set of numbers following articles/
. In the following example, the identifier is "1234567899"
It can also be found in the article settings panel in the Pylon app, under the article slug input.
Last updated