This article details how to trigger a bot when your website visitor clicks a link or button.
Gobot provides several options to control when and how a bot is triggered on your website. These options range from a simple delay timer up to more complex conditions like page scroll position or first-time vs repeat visitors. However, you may want to give your visitors the option of manually triggering a bot themselves. Gobot provides three methods for these cases:
- Gobot’s toggle button
- Keyword-based URL trigger
- Javascript API
Gobot toggle button
The first method is simply using Gobot’s built-in toggle button. By default, bots are configured to add a toggle button which stays at the edge of the browser window. The button position, color and style is fully customizable.
Follow these steps to configure the toggle button:
- Select your bot from the bot dashboard and click Bot Settings from the right panel.
- On the General tab, find the section labeled, “Select how the bot runs”, and select the “Remains on your site at all times” option (this is the default for new bots).
- Switch to the Style tab.
- Scroll down to the Widget Style section. Here you can change how the button looks, change the colors and text, and even upload your business logo or another image.
You can still configure the other popup conditions for the bot from the Triggers tab. The visitor will still be able to trigger the bot by clicking the toggle button.
Keyword-based URL trigger
The second method uses a URL anchor as a keyword trigger. Gobot gives you control over which page or pages your bot is allowed to run. One of the options is setting a bot to run on pages when the URL contains a certain keyword. You can use this to trigger a bot when the visitor clicks a particular link by using an anchor as the link URL and setting the anchor as the bot keyword.
An anchor in a URL is the last portion of the URL which follows the hash or pound (#) sign. For example, the URL, http://www.getgobot.com/#example, has “#example” as the anchor. These anchor are commonly used to scroll to specific portions of the page without causing the browser to reload or navigate away from the page.
Follow these steps to configure a URL trigger using an anchor link. The instructions will use the getgobot.com domain and #example as the keyword, but you will need to change these for your website and use case.
- Select your bot from the bot dashboard and click Bot Settings from the right panel.
- On the General tab, find the section labeled, “Select how the bot runs”, and select the “Pops up under certain conditions” option.
- Scroll down to the section labeled, “Tell us what website you want your bot to run on”, and configure the “Bot will operate” setting based on your use case:
- If your trigger link is only found on one or a couple of pages then you can use the “on a specific page(s)” option. Simply add your URL(s), making sure to append the anchor at the end of each one. For example, https://getgobot.com/page1#example and https://getgobot.com/some/page#example
- If your trigger link is found in multiple pages or throughout your entire site then you can avoid listing all of the URLs by using the “visitor’s URL contains” option.
- Set your website domain for the “Bot will operate on this website” field.
- Set your anchor (#example) for the “on all pages with URLs that contain” field.
- Click Save and Continue to save your changes.
- Publish your bot
- Add a link on your website which links to your anchor. How you do this depends on your website platform. Below is an example of the link HTML:
<a href=”#example”>Trigger Gobot</a>
Note that if the visitor closes the chat popup then clicking the link again will not trigger the bot. This is because the URL already contains the anchor keyword so Gobot cannot detect the second click. Navigating to a different URL (including removing the anchor or a different anchor on the same page) would allow the bot to trigger again.
Javascript API
Gobot provides a basic javascript API which can be used to either trigger a bot or hide the chat window. Use of this API requires some javascript knowledge and the implementation will vary depending on your use case and website platform.
The API is automatically loaded on your website as part of the Gobot client. The Gobot client adds a function called “gobot” which is attached to the window object. The two API methods are documented below:
Trigger a specific bot
gobot('show', '[BOT ID]')
Replace [BOT ID] with the unique id of your bot. You can find this ID by selecting your bot from the bot dashboard and copying the end of the URL.
BOT ID is required. If you don’t provide an id or provide an ID for a bot which is not configured to run on the page then the call will do nothing.
Hide the chat window
gobot('hide')
This will simply hide the active chat window.
Copyright 2019-2020, Gobot LLC, All rights reserved.