From b3875a19d7318fd1ef681d79ee2a13147ee8d166 Mon Sep 17 00:00:00 2001 From: Zeno Kapitein Date: Wed, 11 Mar 2026 10:46:10 +0100 Subject: [PATCH] Add `assistantName` property to Docs Embed (#4095) --- .changeset/afraid-peas-argue.md | 5 ++++ .changeset/orange-pillows-begin.md | 5 ++++ packages/embed/README.md | 15 ++++++++++ packages/embed/src/client/protocol.ts | 6 ++++ packages/embed/src/react/GitBookFrame.tsx | 14 +++++++++- packages/gitbook/src/components/AI/useAI.tsx | 9 +++--- .../gitbook/src/components/AIChat/AIChat.tsx | 2 +- .../Embeddable/EmbeddableAIChat.tsx | 8 +++--- .../EmbeddableAIContextProvider.tsx | 28 +++++++++++++++++++ .../Embeddable/EmbeddableRootLayout.tsx | 6 ++-- 10 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 .changeset/afraid-peas-argue.md create mode 100644 .changeset/orange-pillows-begin.md create mode 100644 packages/gitbook/src/components/Embeddable/EmbeddableAIContextProvider.tsx diff --git a/.changeset/afraid-peas-argue.md b/.changeset/afraid-peas-argue.md new file mode 100644 index 000000000..317529092 --- /dev/null +++ b/.changeset/afraid-peas-argue.md @@ -0,0 +1,5 @@ +--- +"@gitbook/embed": minor +--- + +Support `assistantName` property to override Assistant name diff --git a/.changeset/orange-pillows-begin.md b/.changeset/orange-pillows-begin.md new file mode 100644 index 000000000..7bb5f528c --- /dev/null +++ b/.changeset/orange-pillows-begin.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Refactor embeddable context to merge local & site properties in one unified way diff --git a/packages/embed/README.md b/packages/embed/README.md index 4c24868b9..096546c05 100644 --- a/packages/embed/README.md +++ b/packages/embed/README.md @@ -49,6 +49,7 @@ GitBook('configure', { } ], greeting: { title: 'Welcome!', subtitle: 'How can I help?' }, + assistantName: 'Support Assistant', suggestions: ['What is GitBook?', 'How do I get started?'], tools: [/* ... */], closeButton: true, @@ -100,6 +101,7 @@ frame.configure({ } ], greeting: { title: 'Welcome!', subtitle: 'How can I help?' }, + assistantName: 'Support Assistant', suggestions: ['What is GitBook?', 'How do I get started?'], tools: [/* ... */], closeButton: true @@ -126,6 +128,7 @@ import { GitBookProvider, GitBookFrame } from '@gitbook/embed/react'; }} tabs={['assistant', 'docs']} greeting={{ title: 'Welcome!', subtitle: 'How can I help?' }} + assistantName="Support Assistant" suggestions={['What is GitBook?', 'How do I get started?']} actions={[ { @@ -328,6 +331,18 @@ greeting: { } ``` +### `assistantName` + +Available in: Standalone script, NPM package, React components + +Override the assistant name displayed in the chat header and assistant entry points (for example, sidebar tabs and action labels). This name will be limited to 32 characters to prevent text overflow. + +- **Type**: `string` + +```javascript +assistantName: 'Support Assistant' +``` + ### `suggestions` Available in: Standalone script, NPM package, React components diff --git a/packages/embed/src/client/protocol.ts b/packages/embed/src/client/protocol.ts index 7413783b8..2f5fcadcf 100644 --- a/packages/embed/src/client/protocol.ts +++ b/packages/embed/src/client/protocol.ts @@ -62,6 +62,12 @@ export type GitBookEmbeddableConfiguration = { subtitle: string; }; + /** + * Override the assistant name displayed in the UI. + * Limited to 32 characters. + */ + assistantName?: string; + /** Suggestions of questions to be displayed in the welcome page. */ suggestions: string[]; diff --git a/packages/embed/src/react/GitBookFrame.tsx b/packages/embed/src/react/GitBookFrame.tsx index 479943b55..28bee3449 100644 --- a/packages/embed/src/react/GitBookFrame.tsx +++ b/packages/embed/src/react/GitBookFrame.tsx @@ -27,6 +27,7 @@ export function GitBookFrame(props: GitBookFrameProps) { tabs = ['assistant', 'docs'], trademark = true, closeButton = false, + assistantName, } = props; const frameRef = useRef(null); @@ -50,8 +51,19 @@ export function GitBookFrame(props: GitBookFrameProps) { tools, closeButton, trademark, + assistantName, }); - }, [gitbookFrame, actions, greeting, suggestions, tools, tabs, closeButton, trademark]); + }, [ + gitbookFrame, + actions, + greeting, + suggestions, + tools, + tabs, + closeButton, + trademark, + assistantName, + ]); return (