Customization
Overview
In this section, learn how to customize the Kommunicate SDK according to your requirements.
Getting started with customization
Kommunicate provides easy settings to customize different elements (such as fonts, message color, background colors) and enable or disable any particular feature.
Follow these steps:
Download the settings file from here (Right click -> Save as -> Save)
Place the downloaded
applozic-settings.json
file under your app/src/main/assets/ folder.
There are a lot of customization options in the file. Below are some common options available.
Changing the message background colors
You can change the sent/received message background and text color by setting the hex color codes in the below properties in applozic-settings.json
file.
Hiding/Showing media attachment and location sharing options
You can hide or show the media attachments options like camera, emoji, files and location sharing by changing the below values in applozic-settings.json
file.
You can make any of the options 'false' if you want to hide them.
If location sharing functionality is enabled
If you are enabling the location sharing option in the applozic-settings.json
file, make sure to include the below permissions and geo-API key in your AndroidManifest.xml
file.
Add the following permissions in your AndroidManifest.xml
file:
Add your geo-API_KEY in AndroidManifest.xml
file:
Other properties
Below are some more properties which you can customize in the SDK:
Changing fonts
Fonts for some TextViews can be changed by setting the fonts in the applozic-settings.json
file. Add the below property in applozic-settings.json
file to change the fonts for the respective TextViews:
If a particular field is left blank or is not included in the above object, then default font would be used for the same. To change the font, provide either an external font file or select from the list of default android fonts. The details on how to update external or default Android fonts are given below.
Use TTF font file
To use an external font, add the TTF font file under the directory app/src/main/assets/fonts/.ttf
Then specify the font for the specific TextView. For example, to use the above font for the toolbar title, set the path to the property toolbarTitleFont
:
Use Android's default fonts
To use the font from the list of default android fonts, set the font name to the TextView property in the fontModel
object in applozic-settings.json
file. Use fonts from the below list. You can only use one font per TextView, no combinations are allowed.
For example, if you want to use sans_serif
font for the toolbar subtitle TextView, set the font name to the toolbarSubtitleFont
property:
Theme customization
You may not be able to change all the colors from the applozic-settings.json
file. There are some colors such as the status bar/toolbar color, message status icon colors (sent, delivered etc icons) which you need to override in your colors file.
Follow the below steps to override the default colors in Kommunicate:
Add this line in your
tag in the colors.xml file
Add the below colors in your
colors.xml
file and use your own color values in them
NOTE: primary colors such as Tool bar color, message_status_icon_colors can be set from the Kommunicate dashboard
Sample colors.xml file:
Sending additional metadata with messages
If you need to send some additional data with all the messages sent from a device, then you need to set predefined metadata when logging in the user.
For example, if you need to send deviceInformation
with all the messages sent from that device then call the below function in onSuccess
of login or whichever initial method you are calling from Kommunicate:
This data will be sent with all the messages sent from the device.
Pass Custom data to bot platform
Use the below code to send the custom data to bot platform and pass the key-value string to a Map to the below method Kommunicate.updateChatContext
.
Note: Make sure to call this method after login success or conversation builder success.
Set parent activity to the ConversationActivity dynamically
If you have a use case where the conversation is launched from multiple activities, then you can set the parent activity to the conversation activity so that the user navigates back to the parent activity when the app is launched from chat notification. Use the below code to set the parentActivity dynamically:
Speech-to-Text and Text-to-Speech support
The quality of the customer journey is everything in a product. STT and TTS will help you in enhancing the user experience and people with different learning styles prefer using these features, hence we have decided to help our clients in this way and added the support for this.
You can enable the Speech-to-Text and Text-to-Speech using the below setting;
Text to speech: Works only when the conversation is open and a new message is received within the conversation.
Speech to text: The mic button used to record and send audio will function as STT starter. Just click the button once and the device will start listening. To cancel an ongoing listening, click on the button again. The audio button will scale animate depending on the input voice amplitude. The partial results will be set on the message edit text but the send message button will only be enabled once the complete speech is received. When isSendOnSpeechEnd = true, the message will be sent automatically once the text is received.
To Integrate your own STT or TTS service, replace the KmSpeechToText and KmTextToSpeech implementation with your service.
Last updated