Giter Club home page Giter Club logo

floatbot-android-sdk's Introduction

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

You need to handle Runtime permission for

Sdk has only 1 fragment which can be placed in 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");

To get your key and bot_id,

Login to https://floatbot.ai/console

Note: Please change URL accordingly, if your setup is on-premise or on private cloud, Example: https://domain/console

Once you are logged in please click on Bot API Keys under Developers Section

Select Bot ID and Secret Key against your Bot Name and Key Name Android security token

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);

You can set attributes by encrypting them in json string (data bundle) Or To set attributes directly from SDK

FloatbotAttributes attributes = new FloatbotAttributes();
try {
    attributes.addAttributes("name","user-name");
    bundle.putString("attributes",attributes.value());
} catch (Exception e) {

}

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);

From Sdk version 2.2 You can handle callback url in android app Just implement onCallback() method from OnFloatbotInteractionListener interface in your main activity

 @Override
    public void onCallback(Uri uri) {
        Log.e("callback",uri.toString());
        //finish();
    }

From SDK version 2.3 , you can pass one more parameter in bundle It will create new session everytime when value is set to true (Default value is false)

    bundle.putBoolean("create_new_session",true);

From SDK version 3.2 , you can set/change chatbot domain in SDK It is used to point to that domain [use this settings for on-premise or private cloud setup or public cloud with different region] (Default value is https://floatbot.ai)

    bundle.putString("domain","https://floatbot.ai");

Please let us know if you encounter any problems at [email protected]

floatbot-android-sdk's People

Contributors

floatbotai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.