Skip to content

Commit a4900e5

Browse files
authoredMar 26, 2025
Merge pull request #83 from Cognigy/bug/87618-fix-start-behavior-with-privacy-screen
Bug/87618 fix start behavior with privacy screen
2 parents 2c0b1d0 + 07c77b3 commit a4900e5

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed
 

‎docs/css-customization.md

+12
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ There are several classes that you need to take in consideration if you want to
3434
- _webchat-input-button-add-attachments_
3535
- _webchat-input-drag-and-drop-file-text_
3636
- _webchat-input-button-send_
37+
- _webchat-input-get-started-button_
3738
- _webchat-toggle-button_
3839
- _webchat-unread-message-preview_
3940
- _webchat-unread-message-badge_
@@ -387,6 +388,17 @@ The avatars can be repositioned to appear at the top edge of a message rather th
387388
}
388389
```
389390

391+
- _webchat-input-get-started-button_
392+
The button to initiate the first interaction in the Webchat. You can customize its appearance, size, and background.
393+
394+
```CSS
395+
[data-cognigy-webchat-root] [data-cognigy-webchat].webchat .webchat-input-get-started-button {
396+
397+
border-radius: 10px;
398+
background-color: rgb(0, 123, 255);
399+
}
400+
```
401+
390402
- _webchat-input-button-add-attachments_
391403
The button to open the file attachment section, you can not change the icon but you can customize the position, size and background.
392404

‎src/plugins/get-started-button-input/GetStartedInput.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import styled from "@emotion/styled";
77
const GetStartedButton = styled(Button)(({ theme }) => ({
88
marginBottom: theme.unitSize * 2,
99
flexGrow: 1,
10-
"&:focus": {
11-
outline: "none",
12-
boxShadow: `0 0 3px 1px ${theme.primaryWeakColor}`,
13-
backgroundColor: theme.primaryStrongColor,
14-
},
1510
}));
1611

1712
const GetStartedInput = ({ onSendMessage, config }: InputComponentProps) => (
@@ -26,6 +21,7 @@ const GetStartedInput = ({ onSendMessage, config }: InputComponentProps) => (
2621
}
2722
color="primary"
2823
id="webchatGetStartedButton"
24+
className="webchat-input-get-started-button"
2925
>
3026
{config.settings.startBehavior.getStartedButtonText}
3127
</GetStartedButton>

‎src/plugins/get-started-button-input/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import GetStartedInput from "./GetStartedInput";
22
import { InputRule, InputPlugin } from "../../common/interfaces/input-plugin";
33
import { registerInputPlugin } from "../helper";
4+
import getMessagesListWithoutControlCommands from "../../webchat-ui/utils/filter-out-control-commands";
45

56
const rule: InputRule = ({
67
config: {
@@ -16,7 +17,9 @@ const rule: InputRule = ({
1617
},
1718
messages,
1819
}) =>
19-
(messages.length === 0 || (messages.length === 1 && messages[0].source === "engagement")) &&
20+
(messages.length === 0 ||
21+
(messages.length === 1 && messages[0].source === "engagement") ||
22+
getMessagesListWithoutControlCommands(messages)?.length === 0) &&
2023
startBehavior === "button" &&
2124
!!getStartedPayload &&
2225
(!!getStartedButtonText ||

‎src/webchat/store/autoinject/autoinject-middleware.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ export const createAutoInjectMiddleware =
5858
}
5959

6060
// Don't trigger the auto inject message when the history is not empty
61-
// except if explicitly set via enableAutoInjectWithHistory
61+
// except if explicitly set via enableInjectionWithoutEmptyHistory
6262
if (!config.settings.widgetSettings.enableInjectionWithoutEmptyHistory) {
63+
// If there are stored messages waiting to be sent, don't send the auto-inject message
64+
if (state.ui.storedMessage) {
65+
break;
66+
}
67+
6368
// Exclude engagement messages from state.messages
6469
const messagesExcludingEngagementMessages =
6570
state.messages.messageHistory?.filter(

‎src/webchat/store/connection/connection-middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export const createConnectionMiddleware =
5656
// set options
5757
store.dispatch(setConnecting(false));
5858
store.dispatch(setReconnectionLimit(false));
59-
store.dispatch(setOptions(client.socketOptions));
6059

6160
if (storedMessage) {
6261
store.dispatch(
@@ -67,6 +66,7 @@ export const createConnectionMiddleware =
6766
);
6867
store.dispatch(setStoredMessage(null));
6968
}
69+
store.dispatch(setOptions(client.socketOptions));
7070
})
7171
.catch(() => {
7272
store.dispatch(setConnecting(false));

0 commit comments

Comments
 (0)
Failed to load comments.