This repository contains code examples for utilizing Gladly APIs to build your own Help Center
This repository should be used as a tool for learning and not as production code!
You don't have to build your own Help Center! You could simply embed the Gladly Help Center embed code on a page on your website to get FAQs set up in a matter of minutes. Click here to view instructions on how to do this!
- A user on Gladly can still use the Answers and Help Center layout functionality to manage the Help Center layout and Answers content
- This code will then retrieve the Help Center layout information from Gladly and show that as a table of contents on the left-hand side of the page
- When a user clicks on an answer on the left-hand side table of contents, the code then utilizes Gladly's APIs to retrieve answer contents and then shows it on the right-hand side of the page
- When a user types in the search bar, the code utilizes Gladly's APIs to search for answers that could potentially match the user's query and displays search results in a container beneath the input bar
- Unlike the default out-of-the-box Gladly embed code, this code does not optimize for any SEO capabilities
- Unlike the default out-of-the-box Gladly embed code, the CSS in this demo is not responsive on mobile devices
Open up build-your-own/index.html
in your favorite code editor
- Set
HELP_CENTER_ID
to your Help Center ID. You can get this value from the Settings > Help Center page in Gladly, then clicking on the 3 dots next to the Help Center and clicking on Embed. The Help Center ID is the value inbrandId
- Set
ORG_ID
to your Organization ID. You can get this value from the GET Organization API - Set
ORG_URL
to your organization URL. This is the domain part only of thegladlyUrl
value in the GET Organization API response body. For example, ifgladlyUrl
here is set tohttps://gladly.us-1.gladly.com
, theORG_URL
should begladly.us-1.gladly.com
- Open
build-your-own/index.html
in Chrome
- First, the code retrieves the help center layout JSON (format:
https://cdn.gladly.com/orgs/configs/help-center/${HELP_CENTER_ID}.json
) - Next, it stores the language and audience ID of this help center in 2 variables:
language
andaudienceId
. Note thataudienceId
isn't always set for a help center - but language always will be - Next, it calls the
answer-titles
public REST API to retrieve answer titles associated with this help centerhttps://${ORG_URL}/api/v1/orgs/${ORG_ID}/help-center/${HELP_CENTER_ID}/answer-titles?lng=${language}&audienceId=${audience}
- It then organizes the answer sections into the left-hand side of the page
- When a user clicks on an answer title on the left-hand side of the page, the code calls the find answer API
https://${ORG_URL}/api/v1/orgs/${ORG_ID}/answers/${answerId}?lng=${language}
and puts thebodyHtml
into the answer container on the right-hand side - When a user types in the search box, the code calls the search answer API
https://${ORG_URL}/api/v1/orgs/${ORG_ID}/answers/search?q=${encodeURIComponent(searchQuery)}&audienceId=${audienceId}&lng=${language}
and then displays search results - When a user clicks on an answer in the search box, the code will retrieve the answer using the find answer API
https://${ORG_URL}/api/v1/orgs/${ORG_ID}/answers/${answerId}?lng=${language}
and puts thebodyHtml
into the answer container on the right-hand side