Control the widget from your own code with these methods and events.
Widget methods
Call methods after the widget loads, inside a loaded handler:
Productlane.on("loaded", () => {
Productlane.set({ user: { email: "[email protected]" } })
})Productlane.open(view?)opens the widget, on the last active view by default.viewcan be"INDEX"(the home screen),"CHANGELOG","DOCS","FEEDBACK"(the contact form),"AICHAT"(the AI agent),"LIVE_CHAT","ROADMAP", or"REQUESTS". Names are case-insensitive, and an unknown name opens the home screen.Productlane.close()closes the widget.Productlane.toggle()opens or closes it.Productlane.disable()hides the widget on the page, andProductlane.enable()brings it back.Productlane.openDocs(urlNameOrId)opens an article, by its URL path such as"get-started/quickstart"or by its id.Productlane.set(options)updates any option you can pass toinit().Productlane.signOut()ends a verified session.Productlane.setContext(),getContext(), andclearContext()manage page context.Productlane.askAi({ message, autoSend? })opens the AI agent chat withmessagefilled in. WithautoSend: trueit sends the message right away.
Productlane.openLiveChat({ message? })opens the chat with your team, without the AI agent.messageis filled in for the user to send.
Widget events
Listen with Productlane.on(event, handler) and stop with Productlane.off(event, handler).
Event | Fires when |
|---|---|
| The widget has fully loaded |
| The widget opens |
| The widget closes |
| The widget toggles |
| A visitor clicks a custom link. The handler gets |
| A docs article opens. The handler gets |
Page context
Tell the AI agent which page or feature the user is looking at, so its answers fit what they are doing. Context is an object of string keys and values.
Productlane.setContext({
page: "dashboard",
feature: "analytics",
plan: "pro",
})
Productlane.getContext() // { page: "dashboard", feature: "analytics", plan: "pro" }
Productlane.clearContext()The context travels with every question the user asks. A user on your analytics dashboard who asks "How do I export this data?" gets an answer about analytics exports, not about the rest of your app.
Custom links
Custom links open in a new tab. To run your own code instead, return false from a customLinkClicked handler and the widget skips opening the URL. Leave the URL blank in the widget settings for a link that only fires the event.
Productlane.on("customLinkClicked", (link) => {
if (link.title === "Start tour") {
startProductTour()
return false
}
})link has the shape { title?: string; url?: string }. With no URL configured, link.url is undefined.
Changelog notifications
Set disableChangelogNotification to true to hide the popup that appears when you publish a changelog, for example for selected users. The widget otherwise works as usual.
Productlane.init({
widgetKey: "<your-widget-key />",
disableChangelogNotification: true,
})