Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ REQUIRED data attributes:

- `data-show-thoughts` — Allow users to see the AI's thought process, if applicable, in responses. If set to "false", users will only see a static "Thinking" indication without the explict thought content. If "true" the user will see the full thought content as well as the real response. Defaults to "false".

- `data-first-message` — Allow the users to send a first message automatically on every startup.

- `data-support-email` — Shows a support email that the user can used to draft an email via the "three dot" menu in the top right. Option will not appear if it is not set.

### `<iframe>` tag HTML embed
Expand Down
2 changes: 1 addition & 1 deletion src/components/ChatWindow/ChatContainer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function ChatContainer({
knownHistory = [],
}) {
const [message, setMessage] = useState("");
const [loadingResponse, setLoadingResponse] = useState(false);
const [loadingResponse, setLoadingResponse] = useState(settings.firstMessage ? true : false);
const [chatHistory, setChatHistory] = useState(knownHistory);

// Resync history if the ref to known history changes
Expand Down
13 changes: 13 additions & 0 deletions src/hooks/chat/useChatHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ export default function useChatHistory(settings = null, sessionId = null) {
settings,
sessionId
);

if (settings.firstMessage && formattedMessages.length === 0) {
formattedMessages.push({ content: settings.firstMessage, role: "user", sentAt: Math.floor(Date.now() / 1000) });
formattedMessages.push({
content: "",
role: "assistant",
pending: true,
userMessage: settings.firstMessage,
animate: true,
sentAt: Math.floor(Date.now() / 1000),
});
}

setMessages(formattedMessages);
setLoading(false);
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useScriptAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const DEFAULT_SETTINGS = {
supportEmail: null, // string of email for contact
username: null, // The display or readable name set on a script
defaultMessages: [], // list of strings for default messages.
firstMessage: null,
};

export default function useGetScriptAttributes() {
Expand Down