Skip to content

Commit cf0f7ab

Browse files
Add freshdesk integration (#1019)
* Initial freshdesk integration * add more instructuions * Publish * lock file
1 parent 242d030 commit cf0f7ab

File tree

9 files changed

+157
-1
lines changed

9 files changed

+157
-1
lines changed

.changeset/odd-buttons-send.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-freshdesk': major
3+
---
4+
5+
Initial publish

bun.lock

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@
122122
"@gitbook/tsconfig": "workspace:*",
123123
},
124124
},
125+
"integrations/freshdesk": {
126+
"name": "@gitbook/integration-freshdesk",
127+
"version": "0.1.0",
128+
"dependencies": {
129+
"@gitbook/api": "*",
130+
"@gitbook/runtime": "*",
131+
},
132+
"devDependencies": {
133+
"@gitbook/cli": "workspace:*",
134+
"@gitbook/tsconfig": "workspace:*",
135+
},
136+
},
125137
"integrations/front": {
126138
"name": "@gitbook/integration-front",
127139
"version": "1.0.0",
@@ -531,7 +543,7 @@
531543
},
532544
"integrations/salesforce-chat": {
533545
"name": "@gitbook/integration-salesforce-chat",
534-
"version": "0.1.0",
546+
"version": "0.1.1",
535547
"dependencies": {
536548
"@gitbook/api": "*",
537549
"@gitbook/runtime": "*",
@@ -1056,6 +1068,8 @@
10561068

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

1071+
"@gitbook/integration-freshdesk": ["@gitbook/integration-freshdesk@workspace:integrations/freshdesk"],
1072+
10591073
"@gitbook/integration-front": ["@gitbook/integration-front@workspace:integrations/front"],
10601074

10611075
"@gitbook/integration-fullstory": ["@gitbook/integration-fullstory@workspace:integrations/fullstory"],
141 KB
Loading
232 KB
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: freshdesk
2+
title: Freshdesk
3+
icon: ./assets/freshworks-icon.png
4+
previewImages:
5+
- ./assets/freshworks-visual.png
6+
description: Add the Freshdesk chat widget to your published GitBook content.
7+
externalLinks:
8+
- label: Website
9+
url: https://freshdesk.com/
10+
- label: Documentation
11+
url: https://support.freshdesk.com/support/solutions/articles/239273-set-up-your-help-widget
12+
visibility: public
13+
script: ./src/index.ts
14+
# The following scope(s) are available only to GitBook Staff
15+
# See https://developer.gitbook.com/integrations/configurations#scopes
16+
scopes:
17+
- site:script:inject
18+
organization: gitbook
19+
contentSecurityPolicy:
20+
font-src: |
21+
freshdesk.com
22+
https://widget.freshworks.com;
23+
script-src: |
24+
widget.freshworks.com;
25+
style-src: |
26+
freshdesk.com
27+
https://widget.freshworks.com;
28+
summary: |
29+
# Overview
30+
31+
The Freshdesk integration for GitBook allows you to display the Freshdesk chat widget on your public documentation to connect and interact with your readers.
32+
33+
# How it works
34+
35+
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.
36+
37+
# Configure
38+
39+
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.
40+
41+
categories:
42+
- analytics
43+
configurations:
44+
site:
45+
properties:
46+
widget_id:
47+
type: string
48+
title: Freshdesk Widget ID
49+
description: Available in your Freshdesk dashboard, under the Widget section
50+
required:
51+
- widget_id
52+
target: site
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@gitbook/integration-freshdesk",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@gitbook/api": "*",
7+
"@gitbook/runtime": "*"
8+
},
9+
"devDependencies": {
10+
"@gitbook/cli": "workspace:*",
11+
"@gitbook/tsconfig": "workspace:*"
12+
},
13+
"scripts": {
14+
"typecheck": "tsc --noEmit",
15+
"publish-integrations-staging": "gitbook publish .",
16+
"check": "gitbook check",
17+
"publish-integrations": "gitbook publish ."
18+
}
19+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {
2+
createIntegration,
3+
FetchPublishScriptEventCallback,
4+
RuntimeContext,
5+
RuntimeEnvironment,
6+
} from '@gitbook/runtime';
7+
8+
import script from './script.raw.js';
9+
10+
type FreshdeskRuntimeContext = RuntimeContext<
11+
RuntimeEnvironment<
12+
{},
13+
{
14+
widget_id?: string;
15+
}
16+
>
17+
>;
18+
19+
export const handleFetchEvent: FetchPublishScriptEventCallback = async (
20+
event,
21+
{ environment }: FreshdeskRuntimeContext,
22+
) => {
23+
const widgetId = environment.siteInstallation?.configuration?.widget_id;
24+
if (!widgetId) {
25+
throw new Error(
26+
`The Freshdesk Widget ID is missing from the configuration (ID: ${
27+
'spaceId' in event ? event.spaceId : event.siteId
28+
}).`,
29+
);
30+
}
31+
32+
return new Response((script as string).replaceAll('<TO_REPLACE>', widgetId), {
33+
headers: {
34+
'Content-Type': 'application/javascript',
35+
'Cache-Control': 'max-age=604800',
36+
},
37+
});
38+
};
39+
40+
export default createIntegration<FreshdeskRuntimeContext>({
41+
fetch_published_script: handleFetchEvent,
42+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
window.fwSettings = {
2+
widget_id: '<TO_REPLACE>',
3+
};
4+
!(function () {
5+
if ('function' != typeof window.FreshworksWidget) {
6+
var n = function () {
7+
n.q.push(arguments);
8+
};
9+
n.q = [];
10+
window.FreshworksWidget = n;
11+
}
12+
})();
13+
14+
(function () {
15+
var s = document.createElement('script');
16+
s.type = 'text/javascript';
17+
s.src = 'https://widget.freshworks.com/widgets/<TO_REPLACE>.js';
18+
s.async = true;
19+
s.defer = true;
20+
document.getElementsByTagName('head')[0].appendChild(s);
21+
})();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@gitbook/tsconfig/integration.json"
3+
}

0 commit comments

Comments
 (0)