Engati - User Guide
...
Deploying the bot
Mobile SDKs
Native Android
15min
1 getting started 1 getting started 1 1 open configure> deploy section of https //app engati com/ 1 2 click on the website chatbot tab, where you will get to see the widget script script initialization script will be like following \<script>engtchat init({“bot key” “\<bot key>”, “e” ”p”,”welcome msg”\ true,”branding key” ”\<branding key>” });\</script> note down ’bot key’ and ’branding key’ from the widget script you can find the \<bot name > in the configure> bot details tab of the portal 2 gradle configuration 2 gradle configuration to get a git project into your build step 1 add the jitpack repository to your build file add it in your root build gradle at the end of repositories, allprojects { repositories { … maven { url ‘https //jitpack io’ step 2 add the dependency dependencies { implementation ‘com engati gitlab engati shared microservices\ android chatbot base 1 5 8’} for accessing latest version for enchatbot please refer https //jitpack io/private#com gitlab engati shared microservices/android chatbot base https //jitpack io/private#com gitlab engati shared microservices/android chatbot base note if your project uses glide library then make sure to use glide version 4 9 0 or above e g implementation ‘com github bumptech glide\ glide 4 11 0’ 3 initializing and launching the bot 3 initializing and launching the bot after importing the dependency, initialize it in your applications from where you want to launch the bot initializing with example settings will look as follows import com en botsdk ui chatbotconfig chatbotconfig getinstance() init (“\<bot key>“, “\<bot name>“,true,”\<branding key>“, \<activity>,”\<bot user id>“,”\<bot chat history>“, \<show done>,”\<language alignment>,”\<header title font>“,”\<header description font>“,\<send button drawable>,\<send button bitmap drawable>); chatbotconfig getinstance() launchbot(“<request code for callback>” ); where, bot key is to be picked up from the admin portal bot name is the name of the bot that you intend to display to the users third parameter is a boolean determining whether the welcome message is displayed or not branding key is set to either default or the branding key that you would’ve received on white label setup activity is the appcontext which will be used for using shared preference bot user id is an unique identifier for the user while building an app, you can anything unique to identify a user uniquely based on your business usecase bot chat history is the chat history limit which the user can set to maintain a chat history up to the mentioned limit in the app show done parameter when set to true enables the done button for a callback from the bot to the user app and disables the button when set to false language alignment parameter is to choose the alignment of the text while conversing between the bot and the user (ltr or rtl) possible values are languagealignment default, languagealignment rtl header title font parameter is to set a custom font for bot header title it should be of type typeface header description font parameter is to set a custom font for bot header description it should be of type typeface send button drawable parameter is to set custom drawable to bot send button it should be of type integer send button bitmap drawable parameter is to set a custom bitmap drawable to bot send button it should be of type integer (optional) optional if you want to pass attributes from the application to chatbot if you want to pass attributes pertinent to user from the application, use the below launch bot code instead of the one mentioned above val userattr arraylist\<userattrs> = arraylist\<userattrs>() userattr add(userattrs("attr1", "value 1")) userattr add(userattrs("attr2", "value 2")) chatbotconfig getinstance() setdataattributes(userattr) chatbotconfig getinstance() launchbot() and create one userattrs data class data class userattrs(val name string, val value string) in the above replace the following under 'userattrs' "attr1" name of the attribute that will be created, "value 1" value of the same attribute in a similar manner, multiple attributes can be created and the used in the chatbot flow for automation and personalization in paths 4 additional customizations 4 additional customizations creating a typeface object here are the steps to create a typeface add font ttf to assets folderyou need to add the \<font ttf> file in your asset folder create typeface from assets typeface typeface = typeface createfromasset( getassets(),“\<font ttf>”); where, \<font ttf> refers to the font folder in your asset folder in your app in order to launch the bot activity to start the chat with the bot you just need to launch the chatactivity after the bot initialization for normal (full screen) window chatbogconfig getinstance() launchbot(“<request code for callback>” ); for pop up windows you need to create a blank activity which would hold the bot fragment please see the sample code for more information startactivityforresult(new intent(this,\<your custom activity> class),“<request code for callback>”); where, your custom activity the first parameter refers to the activity in which you will inflate the bot fragment request code for callback to be entered by the user for starting bot and getting a callback respectively inside activity you need to write the following line of code to open bot import com en botsdk ui chatfragment; chatbotconfig getinstance() init (“\<bot key>“, “\<bot name>“,true,”\<branding key>“, \<activity>,”\<bot user id>“,”\<bot chat history>“, \<show done>,”\<language alignment>,”\<header title font>“,”\<header description font>“,\<send button drawable>,\<send button bitmap drawable>); getsupportfragmentmanager() begintransaction() add(r id frame container, new chatfragment()) commit(); where, frame container first parameter refers to parent layout id of your blank activity chatfragment second parameter refers to the botfragment which you need to inflate add “bottheme” style to your custom made activity done button callback you will receive a callback in your activity’s overridden method “onactivityresult” it will be like @overrideprotected void onactivityresult(int requestcode, int resultcode, @nullable intent data) { super onactivityresult(requestcode, resultcode, data); if (resultcode == result ok) { if (request code for callback == request code callback) { if (data != null){ chatresult result = (chatresult) data getserializableextra(“result data”); toast maketext(this, result getexiturl(), toast length short) show(); } } }} where, request code callback is the constant that you pass in the launchbot() function the data we receive will have a specific pattern model public class chatresult implements serializable { private string exiturl; public string getexiturl() { return exiturl; } public void setexiturl(string exiturl) { this exiturl = exiturl; }} sample demo app please find below link for demo app for chat sdk https //branding resources s3 ap south 1 amazonaws com/default/android sdk app/engatifreshtest zip