Skip to content

Commit

Permalink
[CAI-134] Hotfix/chatbot/cai 134 unauthenticated user chatbot message (
Browse files Browse the repository at this point in the history
…#1113)

* Add guest message

* add changeset

---------

Co-authored-by: Marco Ponchia <[email protected]>
  • Loading branch information
Sebastiano-Bertolin and MarcoPonchia authored Sep 24, 2024
1 parent 366c864 commit b278f87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-bobcats-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": minor
---

Guest chatbot message
11 changes: 9 additions & 2 deletions apps/nextjs-website/src/components/molecules/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { compact } from 'lodash';
import { useTranslations } from 'next-intl';
import { ChatCatbotWriting } from '@/components/atoms/ChatChatbotWriting/ChatChatbotWriting';
import { ChatSkeleton } from '@/components/atoms/ChatSkeleton/ChatSkeleton';
import { useUser } from '@/helpers/user.helper';
import { baseUrl } from '@/config';
import AlertPart from '@/components/atoms/AlertPart/AlertPart';
import { ChatbotErrorsType } from '@/helpers/chatbot.helper';

Expand All @@ -35,9 +37,14 @@ const Chat = ({
const t = useTranslations();
const { palette } = useTheme();
const [instantScroll, setInstantScroll] = useState(scrollToBottom);
const { user } = useUser();
const messages = useMemo(
() => [
firstMessage(t('chatBot.welcomeMessage')),
firstMessage(
user
? t('chatBot.welcomeMessage')
: t('chatBot.guestMessage', { host: baseUrl })
),
...compact(
queries.flatMap((q) => [
q.question && q.queriedAt
Expand All @@ -61,7 +68,7 @@ const Chat = ({
])
),
],
[queries, t]
[queries, t, user]
) satisfies Message[];

const scrollRef = useRef<HTMLDivElement>(null);
Expand Down
1 change: 1 addition & 0 deletions apps/nextjs-website/src/messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@
"feedbackGiven": "Feedback\nregistrato",
"copied": "Copiato",
"welcomeMessage": "**Benvenuto nel Dev Portal!**\n\nSono _Discovery_, il tuo assistente virtuale per la documentazione tecnica. Posso aiutarti con informazioni su API, guide, e altro.\n\n_Nota_: Discovery è in versione beta, quindi alcune risposte potrebbero non essere accurate. Verifica sempre le informazioni importanti con la documentazione ufficiale.\n\nCome posso aiutarti oggi?",
"guestMessage": "Ciao sono _Discovery_ , il chatbot di DevPortal!\n\nPosso aiutarti a trovare in modo semplice e rapido le informazioni presenti nella documentazione del Portale.\n\nPer poter accedere al servizio, ti invito a [iscriverti a PagoPA DevPortal]({host}/auth/login)",
"errors": {
"title": "Errore",
"serviceDown": "Il chatbot al momento non è disponibile. Riprovare più tardi.",
Expand Down

0 comments on commit b278f87

Please sign in to comment.