Skip to content

Commit 16814f2

Browse files
authored
Merge pull request #198 from couchbase/DOC-14221-move-to-ask-ai
DOC-14221 move to ask ai
2 parents 1af880e + 67e27c0 commit 16814f2

3 files changed

Lines changed: 61 additions & 9 deletions

File tree

src/js/12-chatbox.js

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
;(function () {
22
var iframeLoader = new window.ChatBotUiLoader.IframeLoader()
33

4-
const iframeOrigin = document.head.querySelector(
5-
'meta[name="page-chatbot-origin"]')?.content ||
4+
const qs = (q) => document.head.querySelector(q)?.content
5+
6+
const iframeOrigin = qs('meta[name="page-chatbot-origin"]') ||
67
'https://d2sozpdiqok6m4.cloudfront.net'
78

89
const origin = window.parent.origin
@@ -36,12 +37,60 @@
3637
},
3738
}
3839

40+
const clientContext = {
41+
product: {
42+
value: qs('meta[name="docsearch:component_title"]'),
43+
description: 'The specific product the user is reading about',
44+
},
45+
surface: {
46+
value: 'docs',
47+
description: 'The user is reading the Couchbase Docs',
48+
},
49+
service: {
50+
value: qs('meta[name="docsearch:component_title"]'),
51+
description: 'The specific product the user is reading about.',
52+
},
53+
page: {
54+
route: {
55+
value: qs('meta[name="page-url"]'),
56+
description: 'The URL of the current page the user is reading',
57+
},
58+
breadcrumbs: {
59+
value: qs('meta[name="docsearch:breadcrumbs"]'),
60+
description: 'The navigation path to the current page',
61+
},
62+
title: {
63+
value: document.head.querySelector('title')?.innerHTML,
64+
description: 'The title of the current page the user is reading',
65+
},
66+
description: 'The specific page the user is on, which can give context for their query',
67+
},
68+
component: {
69+
id: {
70+
value: qs('meta[name="docsearch:component_title"]'),
71+
description: 'The component that the user is reading about',
72+
},
73+
edition: {
74+
value: qs('meta[name="docsearch:edition"]'),
75+
description: 'The edition (e.g. Enterprise or Community) of the product the user is reading about',
76+
},
77+
version: {
78+
value: qs('meta[name="docsearch:cversion"]'),
79+
description: 'The version of the product the user is reading about',
80+
},
81+
description: 'The component that the user is reading about',
82+
},
83+
}
84+
3985
// load the iframe
4086
iframeLoader
4187
.load(chatbotUiconfig)
4288
.then(function () {
4389
iframeLoader.api.ping()
90+
4491
// perform actions on the parent dependent on the chatbot loading.
92+
iframeLoader.api.setClientContext(clientContext)
93+
4594
// document.getElementById('send-intent').setAttribute('disabled', false)
4695
})
4796
.catch(function (error) {

0 commit comments

Comments
 (0)