When the assistant is embedded in a web page, users can open or close it using its built-in controls. It's also possible to add links, buttons, or scripts to the page that provide alternate ways to open or close the assistant.
As long as Mavenoid is embedded on the page, you can call mavenoid.push
and specify one of several events depending on the desired behavior.
assistant-mount
: Load the assistant with the configuration specified through all other included parameters (see Assistant embed API for options). If the assistant was already loaded, this reloads it with the new configuration.
assistant-open
: Open the assistant if it has already been loaded with a assistant-mount
event.
assistant-close
: Close the assistant if it is currently open.
assistant-unmount
: Unload the assistant from the page. To open it again, it will first need to be reloaded with another assistant-mount
event.
For example, this JavaScript will open an assistant that's been embedded normally:
mavenoid.push({ event: "assistant-open" });
To create a link or button to open or close the assistant, write the JavaScript and add it to the page's HTML.
To create a link that will run JavaScript, set the script as the <a>
element's href
attribute, prefixed with javascript:
.
For example, a link that opens the assistant would look something like this:
<a href="javascript:mavenoid.push({ event: 'assistant-open' });">Open assistant</a>
In context, that might look something like this:
<p>If you need to troubleshoot your product, try our <a href="javascript:mavenoid.push({ event: 'assistant-open' });">interactive assistant</a>.</p>
To create a button that will run JavaScript, set the script as the <button>
element's onclick
attribute.
or example, a button that opens the assistant would look something like this:
<button onclick="mavenoid.push({ event: 'assistant-open' })">Open assistant</button>