Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-buttons-send.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gitbook/integration-freshdesk': major
---

Initial publish
16 changes: 15 additions & 1 deletion bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
"@gitbook/tsconfig": "workspace:*",
},
},
"integrations/freshdesk": {
"name": "@gitbook/integration-freshdesk",
"version": "0.1.0",
"dependencies": {
"@gitbook/api": "*",
"@gitbook/runtime": "*",
},
"devDependencies": {
"@gitbook/cli": "workspace:*",
"@gitbook/tsconfig": "workspace:*",
},
},
"integrations/front": {
"name": "@gitbook/integration-front",
"version": "1.0.0",
Expand Down Expand Up @@ -531,7 +543,7 @@
},
"integrations/salesforce-chat": {
"name": "@gitbook/integration-salesforce-chat",
"version": "0.1.0",
"version": "0.1.1",
"dependencies": {
"@gitbook/api": "*",
"@gitbook/runtime": "*",
Expand Down Expand Up @@ -1056,6 +1068,8 @@

"@gitbook/integration-formspree": ["@gitbook/integration-formspree@workspace:integrations/formspree"],

"@gitbook/integration-freshdesk": ["@gitbook/integration-freshdesk@workspace:integrations/freshdesk"],

"@gitbook/integration-front": ["@gitbook/integration-front@workspace:integrations/front"],

"@gitbook/integration-fullstory": ["@gitbook/integration-fullstory@workspace:integrations/fullstory"],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions integrations/freshdesk/gitbook-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: freshdesk
title: Freshdesk
icon: ./assets/freshworks-icon.png
previewImages:
- ./assets/freshworks-visual.png
description: Add the Freshdesk chat widget to your published GitBook content.
externalLinks:
- label: Website
url: https://freshdesk.com/
- label: Documentation
url: https://support.freshdesk.com/support/solutions/articles/239273-set-up-your-help-widget
visibility: public
script: ./src/index.ts
# The following scope(s) are available only to GitBook Staff
# See https://developer.gitbook.com/integrations/configurations#scopes
scopes:
- site:script:inject
organization: gitbook
contentSecurityPolicy:
font-src: |
freshdesk.com
https://widget.freshworks.com;
script-src: |
widget.freshworks.com;
style-src: |
freshdesk.com
https://widget.freshworks.com;
summary: |
# Overview

The Freshdesk integration for GitBook allows you to display the Freshdesk chat widget on your public documentation to connect and interact with your readers.

# How it works

Automatic chat widget on your documentation: Each of your connected GitBook sites will fetch the Freshdesk chat widget script and inject it in your published content.

# Configure

You can configure the integration on single or multiple public sites by navigating to the integrations in sub-navigation or org settings. You will then have to provide Freshdesk widget ID to finish the configuration. This can be found in your Freshdesk dashboard, under the Widget section.

categories:
- analytics
configurations:
site:
properties:
widget_id:
type: string
title: Freshdesk Widget ID
description: Available in your Freshdesk dashboard, under the Widget section
required:
- widget_id
target: site
19 changes: 19 additions & 0 deletions integrations/freshdesk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@gitbook/integration-freshdesk",
"version": "0.1.0",
"private": true,
"dependencies": {
"@gitbook/api": "*",
"@gitbook/runtime": "*"
},
"devDependencies": {
"@gitbook/cli": "workspace:*",
"@gitbook/tsconfig": "workspace:*"
},
"scripts": {
"typecheck": "tsc --noEmit",
"publish-integrations-staging": "gitbook publish .",
"check": "gitbook check",
"publish-integrations": "gitbook publish ."
}
}
42 changes: 42 additions & 0 deletions integrations/freshdesk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
createIntegration,
FetchPublishScriptEventCallback,
RuntimeContext,
RuntimeEnvironment,
} from '@gitbook/runtime';

import script from './script.raw.js';

type FreshdeskRuntimeContext = RuntimeContext<
RuntimeEnvironment<
{},
{
widget_id?: string;
}
>
>;

export const handleFetchEvent: FetchPublishScriptEventCallback = async (
event,
{ environment }: FreshdeskRuntimeContext,
) => {
const widgetId = environment.siteInstallation?.configuration?.widget_id;
if (!widgetId) {
throw new Error(
`The Freshdesk Widget ID is missing from the configuration (ID: ${
'spaceId' in event ? event.spaceId : event.siteId
}).`,
);
}

return new Response((script as string).replaceAll('<TO_REPLACE>', widgetId), {
headers: {
'Content-Type': 'application/javascript',
'Cache-Control': 'max-age=604800',
},
});
};

export default createIntegration<FreshdeskRuntimeContext>({
fetch_published_script: handleFetchEvent,
});
21 changes: 21 additions & 0 deletions integrations/freshdesk/src/script.raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
window.fwSettings = {
widget_id: '<TO_REPLACE>',
};
!(function () {
if ('function' != typeof window.FreshworksWidget) {
var n = function () {
n.q.push(arguments);
};
n.q = [];
window.FreshworksWidget = n;
}
})();

(function () {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'https://widget.freshworks.com/widgets/<TO_REPLACE>.js';
s.async = true;
s.defer = true;
document.getElementsByTagName('head')[0].appendChild(s);
})();
3 changes: 3 additions & 0 deletions integrations/freshdesk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@gitbook/tsconfig/integration.json"
}