How to Integrate the Business Messaging SDK with Flutter Apps

How to Integrate the Business Messaging SDK with Flutter Apps

To install the plugin in your project, run either of the below mentioned commands:
  1. flutter pub add business_messaging_sdk
(or)

add the following in pubspec.yaml
  1. dependencies:
    business_messaging_sdk: ^1.0.0

Android

The Business Messaging SDK's dependencies are available at maven.zohodl.com. To include them in your Android project, you must add the relevant Maven URLs to your project's build.gradle file.

 

To perform this, open the Android folder of your Flutter project in Android Studio and add the following Maven repository to the project-level build.gradle file.

  1. allprojects 

    {  

      repositories 

      {  

      maven { url 'https://maven.zohodl.com/'} 

      maven { url 'https://downloads.zohocdn.com/wmslibrary' } 

      } 

    }

iOS

There is no need to import iOS-specific dependencies separately into the project since the iOS SDK dependencies are automatically added to Flutter projects through the native part of the Flutter plugin.

How to show the Business Messaging SDK on the Flutter Apps?

The following three keys are essential to initialize the SDK in your app:

  • Organization ID (Org Id)
  • AppId 
  • Domain
  1. import 'package:business_messaging_sdk/business_messaging_sdk.dart' show BusinessMessagingSDK;
    BusinessMessagingSDK.show(orgId,appId,domain);

What are session variables?

These variables are dynamically retrieved during the bot conversations. These variables are org-specific and accessible across GC flows.
You can perform these actions with the session variable as mentioned:

Set Session Variable:

  1. import 'package:business_messaging_sdk/business_messaging_sdk.dart' show BusinessMessagingSDK;
    List<Map<String, String>> sessionVariable = [{"name": "YOUR VARIABLE NAME", "value" : "YOUR VARIABLE VALUE"}, {"name": "YOUR VARIABLE NAME", "value": "YOUR VARIABLE VALUE" }]; 
    BusinessMessagingSDK.setSessionVariable(appId,sessionVariable);

Update Session Variable:

  1. import 'package:business_messaging_sdk/business_messaging_sdk.dart' show BusinessMessagingSDK;
    List<Map<String, String>> sessionVariable = [{"name": "YOUR VARIABLE NAME", "value" : "YOUR VARIABLE VALUE"}, {"name": "YOUR VARIABLE NAME", "value": "YOUR VARIABLE VALUE" }];
    BusinessMessagingSDK.updateSessionVariable(orgId,appId,domain,sessionVariable);