The HCOptions
class in the Android SDK provides a flexible way to configure and customize chat widget settings. Developers can use this class to fine-tune the widget’s behavior, appearance, and functionality to match their specific requirements.
The HCOptions.Builder
class helps you configure and create an HCOptions
instance in a flexible and streamlined way. It follows the builder pattern, allowing you to chain methods for easy customization.
File Type Support
You can customize the file types users can send through chat using the setMimeTypes(mimeTypes: Array<String>)
builder function.
Default Supported File Types:
- Documents:
.doc
,.docx
,.pdf
- Presentations:
.ppt
,.pptx
- Spreadsheets:
.xls
,.xlsx
- Others:
.zip
,.apk
, and more
Pre-Chat Form Settings
Configure a pre-chat form to collect user information before they send their first message. Use the setPreChatForm(formSettings: HCPreChatForm)
function to manage this form.
For more details, see: Set a pre-chat form for your chat widget
Theme Customization
Customize the chat widget's appearance using the setTheme(theme: HCTheme)
function with the HCTheme
model.
For more details, see: Customize your chat widget
Chat View Types
Configure how the chat widget displays its initial view using the setChatViewType(chatViewType: HcChatViewType)
function. This defines what users see when they open the widget.
You can override the default application settings from your HelpCrunch account. Choose from the following options:
- HcChatViewType.CHAT_ONLY
Displays only the chat screen. The knowledge base is not available. - HcChatViewType.CHAT_FIRST
Opens the chat screen first. The knowledge base is available if it exists. - HcChatViewType.KB_ONLY
Displays only the knowledge base view. The chat screen is not available. - HcChatViewType.KB_FIRST
Opens the knowledge base view first (if available). The chat screen remains accessible.
Code sample
This Kotlin code configures an HCOptions
instance to customize the chat widget with the following settings:
- File Uploads: allows only PNG images and ZIP files.
- Theme: applies a light theme to the chat interface.
- Pre-Chat Form: requires users to enter their Name and Email before starting a chat.
- Chat View: Uses a custom chat layout defined by
HcChatViewType.CUSTOM
.
val options = HCOptions.build {
setMimeTypes(arrayOf("image/png", "application/zip")) // Allow PNG and ZIP file uploads
setTheme(HCTheme.Builder(HCTheme.Type.DARK).build()) // Apply a dark theme to chat
setPreChatForm(HCPreChatForm.build {
withField(
attributeName = "name",
hint = "Name",
isRequired = true
)
withField(
attributeName = "email",
hint = "Email",
isRequired = true,
inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS,
validationRegex = EMAIL_PATTERN
)
withField(
attributeName = "phone",
hint = "Phone",
isRequired = false,
inputType = InputType.TYPE_CLASS_PHONE,
validationRegex = PHONE_PATTERN
)
})
setChatViewType(HcChatViewType.KB_FIRST) // Open KB screen by default
}