NowChatConfiguration class - Android

concept brazil Updated Sep 10, 2026 8 min read NowChatOptionsAndroid.md
Raw file servicenow.com

The NowChatConfiguration class enables you to configure options on a chat session, such as showing a prompt before closing a chat window, disabling features while using chat, applying different conversation options when using chat, and configuring UI components in NowChat.

Parent Topic:Mobile SDK - Android

NowChatConfiguration - NowChatConfiguration(closePrompt: ClosePrompt? = null, disabledFeatures: List<Feature>? = null, conversationOptions: List<ConversationOption>? = null, uiConfiguration: UIConfiguration? = null)

Configures options for the current chat session. This method enables you to show a prompt before closing a chat window, disable features while using chat, apply different conversation options when using chat, and configure UI components in NowChat.

Name

Type

Description

closePrompt

ClosePrompt object

Prompt to display before closing the associated chat window.Call the NowChatConfiguration.ClosePrompt() subclass to define the value of this parameter.

For example:

Text
closePrompt = NowChatConfiguration.ClosePrompt(  header = null,  message = "Are you sure you want to leave?",  acceptButtonTitle = "Yes",  declineButtonTitle = "No")

If you don't want to display a close prompt, pass null.

disabledFeatures

List<NowChatConfiguration.Feature>

List of chat features to disable within the current chat session.Valid value:

START_NEW_CONVERSATION: Hide/disable the StartNew Conversation button that appears in a chat window.

The available chat features are defined in the NowChatConfiguration.Feature enum class.

For example:

Text
disabledFeatures = listOf(NowChatConfiguration.Feature.START_NEW_CONVERSATION)

If you don't want to disable any features, pass null.

conversationOptions

List<ConversationOption>?

List of conversation options to apply to NowChat. Valid values:

  • END_CONVERSATION_ON_EXIT: Ongoing conversation is terminated when exiting the NowChat window.
  • FORCE_NEW_CONVERSATION: Forces a new chat conversation when NowChat starts.

The available conversation options are defined in the NowChatConfiguration.ConversationOption enum class.

For example:

Text
conversationOptions = listOf(NowChatConfiguration.ConversationOption.FORCE_NEW_CONVERSATION),

If you don't want to apply any options, pass null.

uiConfiguration

UIConfiguration?

UIConfiguration values to use to configure UI components in NowChat. Valid values:

  • attachmentUploadButton: Configuration for the AttachmentUploadButton that is shown next to the text input while talking with a live agent.
  • closeButton: Configuration for the CloseButton used for back navigation on the NowChat toolbar.

For example:

Text
uiConfiguration = NowChatConfiguration.UIConfiguration(  closeButton = NowChatConfiguration.CloseButton(    icon = myDrawable  ),  attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false))

To use the default configuration, pass null.

|Type|Description| |----|-----------| |NowChatConfiguration|Returns a NowChatConfiguration object that you can pass when calling the [NowChatService - start\(activity: Activity, themeColors: NowChatTheme = object: NowChatTheme\{\}, contextData: Map<String, Any> = mapOf\(\), chatConfiguration: NowChatConfiguration? = null\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/brazil/markdown/api-reference/cllent-mobile-api-reference/NowChatServiceAndroidAPI.md) method.|

The following code example shows how to call this method.

JavaScript
suspend fun launchChat() {  val chatService = getNowChatService()   //Drawable to use instead of the default NowChat back button.  val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)       val chatConfiguration = NowChatConfiguration(    closePrompt = NowChatConfiguration.ClosePrompt(      header = null,      message = "Are you sure you want to leave?",      acceptButtonTitle = "Yes",      declineButtonTitle = "No"    ),    disabledFeatures = listOf(NowChatConfiguration.Feature.START_NEW_CONVERSATION),    conversationOptions = listOf(NowChatConfiguration.ConversationOption.FORCE_NEW_CONVERSATION),    uiConfiguration = NowChatConfiguration.UIConfiguration(      closeButton = NowChatConfiguration.CloseButton(        icon = myDrawable      ),      attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)    )  )
  chatService?.start(activity, chatConfiguration)}

NowChatConfiguration - AttachmentUploadButton(isVisible: Boolean = true)

Defines the UI configurations to apply to the upload attachment button that appears next to the text input while talking with a live agent.

AttachmentUploadButton is a subclass of the NowChatConfiguration class.

Name

Type

Description

isVisible

Boolean

Flag that indicates the visibility of the upload attachment button.Valid values:

  • true: Upload attachment button is visible.
  • false: Upload attachment button is hidden.

Default: true

|Type|Description| |----|-----------| |Object|UI configuration object.|

The following code example shows how to hide the AttachmentUploadButton.

Text
suspend fun launchChat() {  val chatService = getNowChatService()
  val chatConfiguration = NowChatConfiguration(    uiConfiguration = NowChatConfiguration.UIConfiguration(      attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)    )  )   chatService?.start(activity, chatConfiguration)}

NowChatConfiguration - CloseButton(icon: Drawable?)

Defines the configuration of the close button used for back navigation on the NowChat toolbar. You then pass this object into the NowChatConfiguration() method to configure the close button to use within the chat session.

CloseButton() is a subclass of the NowChatConfiguration class.

Name

Type

Description

icon

Drawable?

Drawable object to use for the close (back) button.You can use the ContextCompat.getDrawable() method to obtain this drawable object.

For example:

Text
val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)

To use the default drawable, pass null.

Default: NowChat back button

|Type|Description| |----|-----------| |Object|Close button configuration object.|

The following code example shows how to set a custom icon for the close button on the NowChat toolbar.

JavaScript
suspend fun launchChat() {  val chatService = getNowChatService()   //Drawable to use instead of the default NowChat back button.  val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)
  val chatConfiguration = NowChatConfiguration(    uiConfiguration = NowChatConfiguration.UIConfiguration(      closeButton = NowChatConfiguration.CloseButton(        icon = myDrawable      )    )  )
  chatService?.start(activity, chatConfiguration)}

NowChatConfiguration - ClosePrompt(header: String, message: String, acceptButtonTitle: String, declineButtonTitle: String)

Creates and returns a ClosePrompt object based on the passed parameters. You then pass this object into the NowChatConfiguration() method to configure the close prompt options within the chat session.

Name

Type

Description

header

String

Text to display on the prompt's header.If you don't want to display a prompt header, pass null.

message

String

Text to display as the prompt's main text.

acceptButtonTitle

String

Text to display on the prompt's primary button for closing the chat window.

declineButtonTitle

String

Text to display on the prompt's secondary button that dismisses the prompt.If you don't want to display a secondary button, pass null.

|Type|Description| |----|-----------| |Object|Prompt to display before closing the associated chat window.|

The following code example shows how to call this method to configure the close prompt.

Java
suspend fun launchChat() {  val chatService = getNowChatService()   val chatConfiguration = NowChatConfiguration(    closePrompt = NowChatConfiguration.ClosePrompt(      header = null,      message = "Are you sure you want to leave?",      acceptButtonTitle = "Yes",      declineButtonTitle = "No"    )  )  chatService?.start(activity, chatConfiguration)}

NowChatConfiguration - UIConfiguration(closeButton: CloseButton? = null, attachmentUploadButton: AttachmentUploadButton? = null, hideServiceNowInProductBranding: Boolean = false, voiceInputButton: VoiceInputButton? = null)

Creates and returns a UIConfiguration object based on the passed parameters. You then pass this object into the NowChatConfiguration() constructor to configure UI components in NowChat.

UIConfiguration is a subclass of the NowChatConfiguration class.

Name

Type

Description

closeButton

CloseButton?

UI configuration for the CloseButton that appears on the NowChat toolbar and is used for back navigation.Call the NowChatConfiguration - CloseButton(icon: Drawable?) subclass to define the value of this parameter.

For example:

Text
val chatConfiguration = NowChatConfiguration(   uiConfiguration = NowChatConfiguration.UIConfiguration(     closeButton = NowChatConfiguration.CloseButton(       icon = myDrawable  ))

attachmentUploadButton

AttachmentUploadButton?

UI configuration for the AttachmentUploadButton that is shown next to the text input while talking with a live agent.Call the NowChatConfiguration - AttachmentUploadButton(isVisible: Boolean = true) subclass to define the value of this parameter.

For example:

Text
val chatConfiguration = NowChatConfiguration(   uiConfiguration = NowChatConfiguration.UIConfiguration(    attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false)  ) )

hideServiceNowInProductBranding

Boolean

Optional. Flag that indicates whether to hide the ServiceNow branding in Virtual Agent.Valid values:

  • true: ServiceNow branding is hidden.
  • false: ServiceNow branding is shown.

Default: false

voiceInputButton

VoiceInputButton?

Optional. UI configuration for the speech-to-text microphone button shown in the text input bar.Default: null (the button is visible)

|Type|Description| |----|-----------| |UIConfiguration|Object containing the UI configurations defined in the provided parameters.|

The following code example calls the UIConfiguration subclass. It sets the icon for the closeButton, hides the attachment upload button, hides ServiceNow branding, and hides the speech-to-text microphone button.

JavaScript
suspend fun launchChat() {     val chatService = getNowChatService()      // Drawable to use instead of the default NowChat back button     val myDrawable = ContextCompat.getDrawable(activity, R.drawable.my_drawable)      val uiConfiguration = NowChatConfiguration.UIConfiguration(         closeButton = NowChatConfiguration.CloseButton(icon = myDrawable),         attachmentUploadButton = NowChatConfiguration.AttachmentUploadButton(isVisible = false),         hideServiceNowInProductBranding = true,         voiceInputButton = NowChatConfiguration.VoiceInputButton(isVisible = false)     )      val chatConfiguration = NowChatConfiguration(         uiConfiguration = uiConfiguration     )      chatService?.start(activity, chatConfiguration) }

NowChatConfiguration - VoiceInputButton(isVisible: Boolean = true)

Defines the UI configurations to apply to the speech-to-text microphone button that appears in the text input bar.

VoiceInputButton is a subclass of the NowChatConfiguration class.

Name

Type

Description

isVisible

Boolean

Optional. Flag that sets the visibility of the speech-to-text microphone button in the text input bar.Valid values:

  • true: The button is visible.
  • false: The button is hidden.

Default: true

|Type|Description| |----|-----------| |VoiceInputButton|Object containing the UI configuration for the speech-to-text microphone button.|

The following code example hides the speech-to-text microphone button.

Java
suspend fun launchChat() {     val chatService = getNowChatService()      val voiceInputButton = NowChatConfiguration.VoiceInputButton(isVisible = false)      val uiConfiguration = NowChatConfiguration.UIConfiguration(         voiceInputButton = voiceInputButton     )      val chatConfiguration = NowChatConfiguration(         uiConfiguration = uiConfiguration     )      chatService?.start(activity, chatConfiguration)}
Search documentation
Search document titles and file paths on the brazil branch