Integrate with Android app


To integrate floatbot sdk in android app first download floatbot aar file from here

Sdk has only 1 fragment which can be placed any activity

Your Activity must implement OnFloatbotInteractionListener interface and override its method onChatWindowClosed


public class SampleActivity extends AppCompatActivity implements FloatbotFragment.OnFloatbotInteractionListener{
....
  //Called when user click on closebutton from chatwindow
  @Override
  public void onChatWindowClosed() {
    finish();
  }
} 

To initialize SDK, We need to pass below paramaters in fragment


 FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
   flb =  new FloatbotFragment(this);
Bundle bundle = new Bundle();
bundle.putString("bot_id","BOT-ID");
bundle.putString("key","BOT-TOKEN");

BOT-ID : Your floatbot bot id BOT-TOKEN : You will get bot token from Floatbot Dashboard -> Settings -> Android Tab

To hide header from chat window, simply pass showHeader value as false. By default value will be true

bundle.putBoolean("showHeader",false);

To show list of sessions to user. You can call showSessions() method of fragment class

flb.showSessions();

To use login architecture in your app. Create a json string and pass encrypted data in bundle Encryption method - 'AES CBC 256'

bundle.putString("data",AES-CBC-256 Encrypted Json String);

To register for push notification, you need to pass gcm/fcm token in bundle as below

bundle.putString("push_token","GCM/FCM TOKEN");

You can also update fcm/gcm token later by calling below function

FloatbotUtils.updatePushToken("GCM/FCM TOKEN"); 

For push notification, you will need to handle json string in onMessageReceived

@Override
public void onMessageReceived(RemoteMessage message) {
  Log.e("fcm-message",message.getData().toString());
  //Create notification	
}

You can also set your own loading screen/no connection (layout), which will be shown when chatbot is loading or when their is no internet access

FloatbotUtils.setLoadingView(this,R.layout.connecting);
FloatbotUtils.setNoInternetConnectionView(this,R.layout.nointernet);

If you have enabled mic in chatbot. You need to handle Mircophone permission in activity before loading fragment

Currently as of now attachment item is not supported in android floatbot sdk

To Delete user/Clear/Logout from Floatbot app

FloatbotUtils.clearUserData(this);

Please let us know if you encounter any problems at support@floatbot.ai

You will find Bot ID and Token in the chatbot settings of your Bot.

  • Go to Chatbot Section of your Dashboard

chatbot development platform

  • Go to Settings of your Chatbot

customer engagement bot

  • Inside Settings of your chatbot, you will find BOT ID and Token.

chatbot for call center

You can have a look at Sample