Gorilla Dash

arrow_back Back to Knowledge Base

Add Gorilla Dash content and a chatbot to your website

download Download PDF

The Gorilla Dash Website SDK connects your website to published Gorilla Dash content. It works with plain JavaScript, Vue, React and other JavaScript frameworks. The browser script also includes the chatbot, so a new website can use one Gorilla Dash script for both.

This guide is for the developer installing it. The JavaScript reference contains copyable installation examples, options and methods. Use the GraphQL reference to choose the content fields to request, or the REST API reference for REST integrations.

Choose the frontend and backend packages separately

  • Frontend: the browser script website-sdk.js adds window.GorillaDash, which fetches website content directly from the browser to Gorilla Dash. Vue is not required. The same client is available as the @gorilladash/website-sdk module on request from Gorilla Dash support.
  • Backend: gorilladash/laravel-website-sdk is a separate Composer package for Laravel queries and caching. Install it when your server needs content for rendering.
  • Script installation: add the browser script https://gorilladash.com/website-sdk.js?v=1 to your pages. This is the supported way to install the SDK today; the @gorilladash/website-sdk module package is not yet available from npm.

Install the browser script

Add one script element pointing to https://gorilladash.com/website-sdk.js?v=1. Set defer and initialise your integration after the script has loaded. It exposes window.GorillaDash. The reference page includes the full script tag and a working query example.

The script is supported on Chrome and Edge 103, Firefox 100 and Safari 16, or later. In older browsers it may fail to load or its content requests may fail, and the chatbot included in it may not start. If your website must offer chat to visitors on older browsers, keep your existing chat-widget.js embed instead, because it does not have this requirement.

To start the chatbot automatically, copy the organisation slug and chatbot ID from your existing chatbot embed into data-org and data-chatbot on the new script. Without those attributes, the content client is available and no chatbot starts automatically.

Connect website content

  1. Exchange the website credentials on your server using the access-token process in the GraphQL reference. Give the browser only the resulting website-scoped bearer token.
  2. Create a content client with GorillaDash.createClient({ accessToken: () => window.websiteAccessToken }). Your integration supplies window.websiteAccessToken; the SDK does not create it.
  3. Call client.query("{ websiteInfo { name url } }"). The promise resolves to the GraphQL data object, so this example returns data.websiteInfo. Pass query variables as the second argument when needed.
  4. Render the returned content and show a useful fallback if the request fails. The client reports HTTP errors and GraphQL errors, and times out after 15 seconds by default.
KEEP PRIVATE CREDENTIALS ON YOUR SERVER
Never put the API Access Token, API secret or server credentials in HTML, browser JavaScript or the script URL. The website Public Key is for cache-clear webhooks, not query authentication. Supply only a website-scoped bearer token to the browser client.

The default content endpoint is https://graphql.gorilladash.com/graphql. Requests go directly to Gorilla Dash without browser cookies. The SDK does not refresh bearer tokens automatically; use the access-token callback to return a renewed token from your own integration.

Keep an existing chatbot working

Existing chat-widget.js installations continue to work and do not need to change. For a new combined installation, use the website script with the same chatbot settings. If a matching legacy embed is already present, the SDK uses that widget instead of creating a second chatbot. To start it later, call GorillaDash.chatbot.load({ org: "your-organisation-slug", chatbot: 42 }) with your own values.

Use modules or Apollo

Unless Gorilla Dash support has supplied the module to you, use the browser script. Module-based applications import createWebsiteClient from @gorilladash/website-sdk. The optional @gorilladash/website-sdk/apollo adapter requires Apollo Client 4 and GraphQL 16. Start with persistedQueries: false for ordinary POST requests; enable persisted queries only after verifying the organisation and website namespace against your endpoint. Importing the module does not start a chatbot: use the browser script for that.

Render pages for search engines and AI crawlers

A browser script alone does not prerender a page. Use server-side rendering or static generation to send populated HTML on the initial page request. Browser updates can then fetch content directly from Gorilla Dash. Create a separate client and cache for each server-rendered request; never share credentials or visitor state across requests.

Check the installation

  • Confirm the website script returns JavaScript successfully and the browser exposes GorillaDash.createClient.
  • Run the website-info query and confirm it returns your intended website.
  • Check that content requests go to Gorilla Dash, and private credentials do not appear in the page source or browser requests.
  • If you enabled the chatbot, confirm one widget appears and opens correctly.
  • For server-rendered sites, inspect the initial HTML to confirm headings and content are present before browser JavaScript runs.