Skip to content

Commit ce390cf

Browse files
Merge pull request #63 from boldare/feat/initial-message
feat(chatbot): allowed to declare the initial messages
2 parents 7ab7de7 + c26452a commit ce390cf

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

apps/spa/src/app/components/chat/chat-messages/chat-messages.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="messages">
2-
@for (message of messages; track message) {
3-
<span #item>
2+
@for (message of initialMessages.concat(messages); track message) {
3+
<span #item>
44
<ai-chat-message [message]="message"></ai-chat-message>
55
</span>
66
} @empty {

apps/spa/src/app/components/chat/chat-messages/chat-messages.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { ChatTipsComponent } from '../chat-tips/chat-tips.component';
2929
],
3030
})
3131
export class ChatMessagesComponent implements AfterViewInit, OnChanges {
32+
@Input() initialMessages: ChatMessage[] = [];
3233
@Input() messages: ChatMessage[] = [];
3334
@Input() isTyping = false;
3435
@Input() tips: string[] = [];

apps/spa/src/app/modules/+chat/containers/chat-iframe/chat-iframe.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ai-configuration-form class="chat__content" />
1414
} @else {
1515
<ai-chat-messages
16+
[initialMessages]="initialMessages"
1617
[messages]="messages()"
1718
[isTyping]="isTyping()"
1819
[tips]="tips"

apps/spa/src/app/modules/+chat/containers/chat-iframe/chat-iframe.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, OnInit } from '@angular/core';
22
import { toSignal } from '@angular/core/rxjs-interop';
3+
import { take } from 'rxjs';
34
import { environment } from '../../../../../environments/environment';
45
import { ChatService } from '../../shared/chat.service';
56
import { ThreadService } from '../../shared/thread.service';
@@ -8,8 +9,8 @@ import { ChatHeaderComponent } from '../../../../components/chat/chat-header/cha
89
import { ChatMessagesComponent } from '../../../../components/chat/chat-messages/chat-messages.component';
910
import { ChatFooterComponent } from '../../../../components/chat/chat-footer/chat-footer.component';
1011
import { ConfigurationFormComponent } from '../../../+configuration/components/configuration-form/configuration-form.component';
11-
import { take } from 'rxjs';
1212
import { SpinnerComponent } from '../../../../components/spinner/spinner.component';
13+
import { ChatMessage } from '../../shared/chat.model';
1314

1415
@Component({
1516
selector: 'ai-chat-iframe',
@@ -37,6 +38,7 @@ export class ChatIframeComponent implements OnInit {
3738
isAttachmentEnabled = environment.isAttachmentEnabled;
3839
isRefreshEnabled = environment.isRefreshEnabled;
3940
isConfigEnabled = environment.isConfigEnabled;
41+
initialMessages: ChatMessage[] = [];
4042
tips = [
4143
'Hello! 👋 How can you help me?',
4244
'What’s the weather like in Warsaw?',

0 commit comments

Comments
 (0)