Before you start
- Role: Manager or higher on the chatbot to copy the code from the Installation page. See Invite and manage team members.
- Access to the HTML of your page, or to a block or element in your website builder that takes HTML and scripts.
- Your chatbot ID. It is on the Installation page.
Show the chat inside the page
Use the inline container. The chat shows in a box on your page, and the floating chat icon does not show.1
Copy the Inline Container code
On the Installation page, in Embed Options, find Inline Container. Select Copy.
2
Paste the code where the search box goes
Paste the code in your page, at the place where you want visitors to ask. For a search-style box, make the container shorter, for example
height: 400px.3
Remove the other embed code from that page
If this page also has the JavaScript embed code, remove it from this page. The inline code already loads the chat with
hideBubble=true.On WordPress
- With the SiteGPT plugin
- Without the plugin
The plugin already loads the chat on every page. Add only the container.
- Open the page in the WordPress editor.
- Add a Custom HTML block where the search box goes.
- Paste only the
<div>line of the code, not the<script>. - Update the page.
Send your search bar to the chat
Keep your own search box. When the visitor submits it, your page sends the text to the chat with the widget SDK. The chat window opens, sends the question, and shows the answer. You do not need to open the chat first.1
Add the embed code to the page
The page needs the normal JavaScript embed code, or the WordPress plugin. See Add SiteGPT to your website. If the chat icon already shows on the page, this is done.
2
Add the search box and the script
Paste this code where the search box goes. You can change the label, the placeholder, the button text, and the style.
3
Test it
Open the page, type a question in the search box, and press Enter or select Ask.
- The script listens for the form’s submit on the whole page, so it works above or below the form, in the header or in the footer.
event.preventDefault()stops the form from loading a search results page.window.$sitegpt.push(['do', 'message:send', question])sends the text as the visitor’s message. The answer shows in the chat window.- Each question goes into the visitor’s current conversation, so the visitor can ask follow-up questions in the chat.
- A visitor message has a length limit. If the text is too long, the chat does not send it and shows an error. See Chat message length.
hideButton=true to the script URL of the embed code: .../widget/YOUR_CHATBOT_ID.js?hideButton=true. The chat window still opens when the visitor submits the search box. See Embed code options.
On WordPress
- Install the SiteGPT plugin, or check that it is active. See Add SiteGPT to your website.
- Open the page in the WordPress editor.
- Add a Custom HTML block where the search box goes.
- Paste the search box code from above.
- Update the page.
<script> when you save, keep the <form> in the block. Then add the <script> part to the footer with a plugin that adds header and footer code.
The plugin adds the chat with its default options, so the chat icon stays on the page. Do not add this page to Excluded Pages. On an excluded page, the chat does not open from your search box.
Check that it works
- Open the page in a new private browser window.
- Ask a question that your content answers.
- The chat shows the question and the answer.
If it does not work
Nothing happens when I submit the search box
Nothing happens when I submit the search box
- Check that the embed code or the WordPress plugin is on the page. View the page source and search for
sitegpt.ai/widget. - Check that the
idvalues in the form and the script match. - If the page is in Excluded Pages, the chat does not open there, unless the embed code uses
hideButton=trueorhideBubble=true. Remove the page from Excluded Pages. See Hide the chat icon on some pages. - If you set Allowed Domains, your website’s domain must be in the list. See Allow only your own websites.
- Open the browser console. Messages from SiteGPT start with
SiteGPT:.
The page reloads or opens a search results page
The page reloads or opens a search results page
The script did not run, so the form did its normal submit. Check that the
<script> is on the page and that your website builder did not remove it. Check that the form has id="sitegpt-search".The floating chat icon shows next to the chat inside the page
The floating chat icon shows next to the chat inside the page
The page has the normal embed code, or the WordPress plugin, as well as the inline code. Remove the normal embed code from that page. With the WordPress plugin, add the page to Excluded Pages.