Skip to content
Last updated

Set chat configuration parameters

To enable the basic version of chat, call the SinchSdk.Chat.mount(); method when the SDK has already been initialized and the user identity set. For more customized experience, you can pass additional properties to the mount method.

ParameterTypeDescription
localeIntl.LocalesArgumentSets the locale for the chat widget.
isLocationPickerEnabledbooleanToggles the location picker functionality in the chat widget.
isEmojiPickerEnabledbooleanToggles the emoji picker functionality in the chat widget.
isDocumentEnabledbooleanToggles the document picker functionality in the chat widget.
isImagePickerAvailablebooleanToggles the image picker functionality in the chat widget.
isBottomBarEnabledbooleanToggles the bottom bar in the chat widget.
isToolbarAvailablebooleanToggles whether the toolbar is available in the chat widget.
darkmodebooleanToggles dark mode.
showDefaultChatButtonbooleanToggles whether the default chat button is available in the chat widget.
showRefreshConversationButtonbooleanEnables the refresh button. Works for anonymous users (without uuid and uuidHash).
showCloseButtonbooleanEnables the close button, which allows users to end the conversation.
showScrollbarbooleanEnables the scrollbar in the chat display area where messages are shown.
hideScrollIndicatorbooleanHides the scroll down to new message indicator.
chatPosition'bottom-right' or 'bottom-left'Sets the position of the chat widget. Defaults to 'bottom-right'.
chatPositionOffsetnumber or number[]Specifies the offset of the chat widget from the corner of the screen.
brandTextstringSets the brand text that displays in the top bar of the chat widget.
brandColorstringSets the brand color of the chat widget.
brandColorLightstringSets the light mode brand color.
brandColorDarkstringSets the dark mode brand color.
defaultAgent{
displayName?: string;
pictureUrl?: string;
}
Allows you to set either a custom client icon or a client name. In the case of the name, the first letter will be displayed in place of the image.
sendInitialMessagebooleanEnables the event that triggers the initiation of a conversation.
collapseChoicesOnPressedbooleanCollapses choice buttons after one is selected.
initialScreenConfigInitialScreenConfigSpecifies the content of the initial screen, which precedes the conversation start or can be optionally disabled.
uiConfigUiConfigDefines the appearance of specific components within the widget.
rtlLayoutbooleanEnables right-to-left layout for languages that require it.
isEndChatEnabledbooleanEnables the end chat functionality in the widget.
multiTopicInboxEnabledbooleanEnables support for multiple topics in the chat inbox.

InitialScreenConfig

ParameterTypeDescription
enabledbooleanDetermines whether the initial screen is enabled.
imageUrlstringSets the main image of the initial screen.
form{ fields: InitialScreenConfigField[] }Defines the form displayed on the initial screen.

InitialScreenConfigField

ParameterTypeDescription
namestringDetermines the unique name of the field that will be sent as metadata in the conversation.
typeHTML Input TypeSpecifies the field type compatible with HTML Input type.
requiredbooleanDetermines whether the field is mandatory.
patternstringSpecifies a regex pattern for input validation.
labelstringSpecifies the label text displayed above the input field.
placeholderstringSpecifies the placeholder for the input.

UiConfig

ParameterTypeDescription
startChatButtonBackgroundColorstringBackground color of the start chat button.
startChatButtonColorstringText color of the start chat button.
navigationBarBackgroundColorstringBackground color of the navigation bar.
navigationCloseChatButtonColorstringColor of the close button in the navigation bar.
navigationCloseChatButtonImagestringCustom image for the close button in the navigation bar.
navigationRefreshChatButtonColorstringColor of the refresh button in the navigation bar.
navigationMinimiseChatButtonColorstringColor of the minimise button in the navigation bar.
fileDocumentMenuImagestringCustom image for the document menu.
openButtonImageUrlstringCustom image URL for the open chat button.
closeButtonImageUrlstringCustom image URL for the close chat button.
messageBackgroundColorstringBackground color for outgoing messages.
messageBorderWidthstringBorder width for outgoing messages.
messageBorderColorstringBorder color for outgoing messages.
messageColorstringText color for outgoing messages.
messageLinkColorstringLink color for outgoing messages.
messageIncomingBackgroundColorstringBackground color for incoming messages.
messageIncomingBorderWidthstringBorder width for incoming messages.
messageIncomingBorderColorstringBorder color for incoming messages.
messageIncomingColorstringText color for incoming messages.
messageIncomingLinkColorstringLink color for incoming messages.
eventBubbleBackgroundColorstringBackground color for event bubbles.
eventBubbleColorstringText color for event bubbles.
scrollIndicatorBackgroundColorstringBackground color of the scroll indicator.
scrollIndicatorColorstringColor of the scroll indicator.
choiceButtonTextTransformstringCSS text-transform value for choice buttons.
choiceButtonBackgroundColorstringBackground color for choice buttons.
choiceButtonBorderWidthstringBorder width for choice buttons.
choiceButtonBorderColorstringBorder color for choice buttons.
choiceButtonColorstringText color for choice buttons.
choiceButtonPressedBackgroundColorstringBackground color for pressed choice buttons.
choiceButtonPressedBorderWidthstringBorder width for pressed choice buttons.
choiceButtonPressedBorderColorstringBorder color for pressed choice buttons.
choiceButtonPressedColorstringText color for pressed choice buttons.

Examples of chat configurations:

Custom chat widget icon

const image = document.createElement('img');
image.src = 'https://example-link-to-image.com';
image.style.position = 'fixed';
image.style.bottom = '0';
image.style.right = '0';
image.style.maxHeight = '100px';
image.style.margin = '20px 30px';
image.style.cursor = 'pointer';
image.style.zIndex = '999';
document.body.append(image);

image.addEventListener('click', () => {
    SinchSdk.Chat.toggle();
})

SinchSdk.Chat.mount({
    chatPositionOffset: [150, 40],
    showDefaultChatButton: false,
});

Custom form on the initial screen

SinchSdk.Chat.mount({
    initialScreenConfig: {
        imageUrl: 'https://example-link-to-image.com',
        form: {
            fields: [
                {
                    name: 'display_name',
                    type: 'text',
                    label: 'Full Name',
                    placeholder: 'Firstname Lastname',
                    required: false,
                },
                {
                    name: 'email',
                    type: 'email',
                    label: 'Email',
                    placeholder: 'Your email address',
                    pattern: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
                    required: true,
                },
            ],
        },
    },
});