Skip to content

Commit c1e1a34

Browse files
committed
Sticky chatbot
1 parent 23377b6 commit c1e1a34

File tree

9 files changed

+50
-6
lines changed

9 files changed

+50
-6
lines changed

backend/files/misc/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11

22

3+
## Version 20.3.0
4+
5+
Minor feature release
6+
7+
* Allowing the chatbot to be 'sticky', implying if it's opened on one page, and the user is navigating, the chatbot opens automatically once loading is done
8+
9+
10+
----
11+
12+
313
## Version 19.11.3
414

515
Minor bug fix release

backend/files/system/openai/front.files/chat/modern.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
animation: '[[animation]]',
4444
popup: '[[popup]]',
4545
extra: '[[extra]]',
46-
hidden: [[hidden]]
46+
hidden: [[hidden]],
47+
sticky: [[sticky]]
4748
},
4849

4950
// References buffer for storing references during invocation.
@@ -278,7 +279,6 @@
278279

279280
// Making sure surface is scrolled to the bottom when opened.
280281
this.hasSessionItems = true;
281-
282282
}
283283

284284
// Making sure we close chatbot with ESC.
@@ -316,6 +316,16 @@
316316
ainiro_faq_question(null, initialPrompt);
317317
}
318318
}, 1);
319+
320+
// Checking if we should show the chatbot by default.
321+
if (this.ainiro_settings.sticky === true) {
322+
const ses = sessionStorage.getItem('ainiro_state');
323+
if (ses === 'open') {
324+
this.show();
325+
}
326+
} else {
327+
sessionStorage.setItem('ainiro_state', 'closed');
328+
}
319329
},
320330

321331
/*
@@ -327,6 +337,7 @@
327337
wnd.parentElement.removeChild(wnd);
328338
const btn = document.getElementById('ainiro_chat_btn');
329339
btn.parentElement.removeChild(btn);
340+
sessionStorage.setItem('ainiro_state', 'closed');
330341
},
331342

332343
/*
@@ -349,7 +360,12 @@
349360
this.includeResources(() => {
350361

351362
// Now we can safely invoke our real show function.
352-
this._show(onAfter);
363+
this._show(() => {
364+
if (onAfter) {
365+
onAfter();
366+
}
367+
sessionStorage.setItem('ainiro_state', 'open');
368+
});
353369
});
354370
},
355371

@@ -877,6 +893,7 @@
877893
if (shopifyChatbot) {
878894
shopifyChatbot.style.display = 'block';
879895
}
896+
sessionStorage.setItem('ainiro_state', 'closed');
880897
},
881898

882899
/*

backend/files/system/openai/include-chatbot.get.hl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
follow_up:bool
2222
new_tab:bool
2323
popup:string
24+
sticky:bool
2425

2526
// Not used, but allows embedders to do a hard refresh to reload JavaScript.
2627
v:string

backend/files/system/openai/include-chatbot.js.get.hl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
animation:string
2525
popup:string
2626
hidden:bool
27+
sticky:bool
2728

2829
// Extra parameter passed into each invocation towards chat endpoint
2930
extra:string
@@ -50,6 +51,7 @@ validators.default:x:@.arguments
5051
animation:
5152
popup:
5253
hidden:bool:false
54+
sticky:bool:false
5355

5456
// Checking if custom JavaScript file exists.
5557
.filename
@@ -128,6 +130,10 @@ set-value:x:@.result
128130
strings.replace:x:@.result
129131
.:[[hidden]]
130132
strings.to-lower:x:@.arguments/*/hidden
133+
set-value:x:@.result
134+
strings.replace:x:@.result
135+
.:[[sticky]]
136+
strings.to-lower:x:@.arguments/*/sticky
131137
set-value:x:@.result
132138
strings.replace:x:@.result
133139
.:[[start]]

backend/slots/Version.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Version : ISlot
2020
/// <param name="input">Parameters passed from signaler</param>
2121
public void Signal(ISignaler signaler, Node input)
2222
{
23-
input.Value = "v20.2.6";
23+
input.Value = "v20.3.0";
2424
}
2525
}
2626
}

frontend/src/app/components/protected/create/chatbot-wizard/chatbot-wizard.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class ChatbotWizardComponent implements OnInit, OnDestroy {
198198
this.dialog
199199
.open(MachineLearningEmbedUiComponent, {
200200
width: '80vw',
201-
maxWidth: '750px',
201+
maxWidth: '850px',
202202
data: {
203203
type: this.model,
204204
landing_page: true,

frontend/src/app/components/protected/manage/machine-learning/components/machine-learning-embed-ui/machine-learning-embed-ui.component.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ <h3 mat-dialog-title class="mb-3">Embed Chatbot or AI Search on your website</h3
253253
matTooltip="Have the chatbot display highlighted code"
254254
color="primary">Code</mat-checkbox>
255255

256+
<mat-checkbox
257+
[(ngModel)]="sticky"
258+
labelPosition="before"
259+
matTooltip="Opens the chatbot during navigation if it's already been opened"
260+
color="primary">Sticky</mat-checkbox>
261+
256262
</div>
257263

258264
</mat-tab>

frontend/src/app/components/protected/manage/machine-learning/components/machine-learning-embed-ui/machine-learning-embed-ui.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export class MachineLearningEmbedUiComponent implements OnInit {
5454
linkColor: string = '#fe8464';
5555
positioning: string = 'right';
5656
animations: string = 'none';
57+
sticky: boolean = false;
5758

5859
constructor(
5960
@Inject(MAT_DIALOG_DATA) public data: any,
@@ -189,6 +190,9 @@ export class MachineLearningEmbedUiComponent implements OnInit {
189190
if (this.animations && this.animations !== 'none') {
190191
url += '&animation=' + this.animations;
191192
}
193+
if (this.sticky) {
194+
url += '&sticky=true';
195+
}
192196

193197
if (html) {
194198
return `<script src="${url}" defer></script>`;

frontend/src/app/components/protected/manage/machine-learning/machine-learning-types/machine-learning-types.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export class MachineLearningModelsComponent implements OnInit {
410410
this.dialog
411411
.open(MachineLearningEmbedUiComponent, {
412412
width: '80vw',
413-
maxWidth: '750px',
413+
maxWidth: '850px',
414414
data: {
415415
type: el.type,
416416
noClose: true,

0 commit comments

Comments
 (0)