Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/87618 fix start behavior with privacy screen #83

Merged
merged 5 commits into from
Mar 26, 2025
Merged
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
12 changes: 12 additions & 0 deletions docs/css-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ There are several classes that you need to take in consideration if you want to
- _webchat-input-button-add-attachments_
- _webchat-input-drag-and-drop-file-text_
- _webchat-input-button-send_
- _webchat-input-get-started-button_
- _webchat-toggle-button_
- _webchat-unread-message-preview_
- _webchat-unread-message-badge_
Expand Down Expand Up @@ -387,6 +388,17 @@ The avatars can be repositioned to appear at the top edge of a message rather th
}
```

- _webchat-input-get-started-button_
The button to initiate the first interaction in the Webchat. You can customize its appearance, size, and background.

```CSS
[data-cognigy-webchat-root] [data-cognigy-webchat].webchat .webchat-input-get-started-button {

border-radius: 10px;
background-color: rgb(0, 123, 255);
}
```

- _webchat-input-button-add-attachments_
The button to open the file attachment section, you can not change the icon but you can customize the position, size and background.

Expand Down
6 changes: 1 addition & 5 deletions src/plugins/get-started-button-input/GetStartedInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import styled from "@emotion/styled";
const GetStartedButton = styled(Button)(({ theme }) => ({
marginBottom: theme.unitSize * 2,
flexGrow: 1,
"&:focus": {
outline: "none",
boxShadow: `0 0 3px 1px ${theme.primaryWeakColor}`,
backgroundColor: theme.primaryStrongColor,
},
}));

const GetStartedInput = ({ onSendMessage, config }: InputComponentProps) => (
Expand All @@ -26,6 +21,7 @@ const GetStartedInput = ({ onSendMessage, config }: InputComponentProps) => (
}
color="primary"
id="webchatGetStartedButton"
className="webchat-input-get-started-button"
>
{config.settings.startBehavior.getStartedButtonText}
</GetStartedButton>
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/get-started-button-input/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import GetStartedInput from "./GetStartedInput";
import { InputRule, InputPlugin } from "../../common/interfaces/input-plugin";
import { registerInputPlugin } from "../helper";
import getMessagesListWithoutControlCommands from "../../webchat-ui/utils/filter-out-control-commands";

const rule: InputRule = ({
config: {
Expand All @@ -16,7 +17,9 @@ const rule: InputRule = ({
},
messages,
}) =>
(messages.length === 0 || (messages.length === 1 && messages[0].source === "engagement")) &&
(messages.length === 0 ||
(messages.length === 1 && messages[0].source === "engagement") ||
getMessagesListWithoutControlCommands(messages)?.length === 0) &&
startBehavior === "button" &&
!!getStartedPayload &&
(!!getStartedButtonText ||
Expand Down
7 changes: 6 additions & 1 deletion src/webchat/store/autoinject/autoinject-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ export const createAutoInjectMiddleware =
}

// Don't trigger the auto inject message when the history is not empty
// except if explicitly set via enableAutoInjectWithHistory
// except if explicitly set via enableInjectionWithoutEmptyHistory
if (!config.settings.widgetSettings.enableInjectionWithoutEmptyHistory) {
// If there are stored messages waiting to be sent, don't send the auto-inject message
if (state.ui.storedMessage) {
break;
}

// Exclude engagement messages from state.messages
const messagesExcludingEngagementMessages = state.messages?.filter(
message => message.source !== "engagement",
Expand Down
2 changes: 1 addition & 1 deletion src/webchat/store/connection/connection-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const createConnectionMiddleware =
// set options
store.dispatch(setConnecting(false));
store.dispatch(setReconnectionLimit(false));
store.dispatch(setOptions(client.socketOptions));

if (storedMessage) {
store.dispatch(
Expand All @@ -67,6 +66,7 @@ export const createConnectionMiddleware =
);
store.dispatch(setStoredMessage(null));
}
store.dispatch(setOptions(client.socketOptions));
})
.catch(() => {
store.dispatch(setConnecting(false));
Expand Down