Skip to content

added stepsailor integration #739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
Binary file added integrations/stepsailor/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions integrations/stepsailor/gitbook-manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: stepsailor
title: Stepsailor Assistant
script: src/index.ts
icon: ./assets/logo.png
description: 'Add the Stepsailor assistant to your documentation'
externalLinks:
- label: Website
url: https://www.stepsailor.com/
visibility: public
target: site
scopes:
- site:script:inject
contentSecurityPolicy:
font-src: |
static.api.stepsailor.com
script-src: |
static.api.stepsailor.com;
https://static.api.stepsailor.com/orion-ai/index.js;
style-src: |
static.api.stepsailor.com
https://static.api.stepsailor.com/orion-ai/main.css;
summary: |
# Overview

The Stepsailor integration for GitBook brings Orion, an AI-powered assistant, to your documentation that enables your users to ask questions and get answers directly within your documentation.

# How it works

Orion provides an in-app AI assistant that answers product questions, displays educational videos within your published content.

# Configure

You can configure the integration on your GitBook spaces by providing your organization ID, deployConfig ID and API Key. These credentials connect your documentation to Stepsailor's knowledge base and enable the AI-powered features in your published content.
configurations:
site:
properties:
organizationId:
type: string
title: Organization ID
description: You can copy that in the deploy config page
deployConfigId:
type: string
title: Deploy Config ID
description: You can copy that in the deploy config page
apiKey:
type: string
title: API Key
description: You can copy that in the deploy config page
required:
- organizationId
- deployConfigId
- apiKey
categories:
- content
organization: GXGct7gbl46efsxXM5JQ
secrets: {}
16 changes: 16 additions & 0 deletions integrations/stepsailor/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "gitbook-orion",
"private": true,
"version": "0.1.0",
"scripts": {
"typecheck": "tsc --noEmit",
"publish": "gitbook publish ."
},
"dependencies": {
"@gitbook/runtime": "*"
},
"devDependencies": {
"@gitbook/cli": "^0.20.1",
"@gitbook/tsconfig": "*"
}
}
52 changes: 52 additions & 0 deletions integrations/stepsailor/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
createIntegration,
FetchPublishScriptEventCallback,
RuntimeContext,
RuntimeEnvironment,
} from '@gitbook/runtime';

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

type StepsailorRuntimeContext = RuntimeContext<
RuntimeEnvironment<
{},
{
organizationId?: string;
deployConfigId?: string;
apiKey?: string;
}
>
>;

export const handleFetchEvent: FetchPublishScriptEventCallback = async (
event,
{ environment }: StepsailorRuntimeContext,
) => {
const organizationId = environment.siteInstallation?.configuration?.organizationId;
const deployConfigId = environment.siteInstallation?.configuration?.deployConfigId;
const apiKey = environment.siteInstallation?.configuration?.apiKey;

if (!organizationId || !deployConfigId || !apiKey) {
throw new Error(
`The Stepsailor organization ID, deploy config ID and API key are missing from the configuration (ID: ${
'spaceId' in event ? event.spaceId : event.siteId
}).`,
);
}

const scriptContent = (script as string)
.replace('<TO_REPLACE_ORGANIZATION_ID>', organizationId)
.replace('<TO_REPLACE_DEPLOY_CONFIG_ID>', deployConfigId)
.replace('<TO_REPLACE_API_KEY>', apiKey);

return new Response(scriptContent, {
headers: {
'Content-Type': 'application/javascript',
'Cache-Control': 'max-age=604800',
},
});
};

export default createIntegration<StepsailorRuntimeContext>({
fetch_published_script: handleFetchEvent,
});
10 changes: 10 additions & 0 deletions integrations/stepsailor/src/script.raw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function (d, s) {
d = document;
s = d.createElement('script');
s.src = 'https://static.api.stepsailor.com/orion-ai/index.js';
s.setAttribute('data-company-id', '<TO_REPLACE_ORGANIZATION_ID>');
s.setAttribute('data-deploy-config-id', '<TO_REPLACE_DEPLOY_CONFIG_ID>');
s.setAttribute('data-secret', '<TO_REPLACE_API_KEY>');
s.async = 1;
d.getElementsByTagName('body')[0].appendChild(s);
})(window, document);
3 changes: 3 additions & 0 deletions integrations/stepsailor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@gitbook/tsconfig/integration.json"
}