Configuration

We have redesigned our APIs in the 2.x version, now you can support your users in a more friendly way.

To help you upgrade from version 1.x to version 2.x, we will take several commonly used scenarios as examples to show your the difference.

UserInfo #

Scenes:

Post user information to SDK whenever user login status changes.

You can set user information via the following method in 1.x version:

ELvaChatServiceSdk.setUserId("user_id");
ELvaChatServiceSdk.setUserName("user_name");
ELvaChatServiceSdk.setServerId("server_id");

But if you expect to post user tags or other custom data to AIHelp, you can only pass them via key-value data when calling showXxxx method:

private void updateUserInfo() {
    HashMap<String, Object> map = new HashMap();

    ArrayList<String> tags = new ArrayList();
    tags.add("pay1");
    tags.add("s1");
    tags.add("vip2");
    map.put("elva-tags", tags); 

    HashMap<String, Object> config = new HashMap();
    config.put("elva-custom-metadata", map);
  	config.put("level", 34);
  	config.put("total_recharge", 300);
  	config.put("remaining", 56);
    ELvaChatServiceSdk.showElva("user_name", "user_id", "server_id", "1", config);
}

If you expect to post user information to CRM automatically, you also need to call setVIP method:

private void syncUserToCRM() {
    HashMap<String, Object> map = new HashMap();
    ArrayList<String> tags = new ArrayList();
    tags.add("pay1");
    tags.add("s1");
    tags.add("vip2");
    map.put("elva-tags", tags); 
    HashMap<String, Object> config = new HashMap();
    config.put("elva-custom-metadata", map);
    ELvaChatServiceSdk.setVIP("user_id", "user_name", config);
}

We have summarized all the above configuration into updateUserInfo method in version 2.x.

Considering that the user-ralated attributes are generally fixed, we have provided a separate updateUserInfo method to update user information in version 2.x.

At the same time, now you can implement CRM synchronization operations in a better way:

private void updateUserInfo() {
    JSONObject customData = new JSONObject();
    customData.put("level", 34);
    customData.put("total_recharge", 300);
    customData.put("remaining", 56);

    UserConfig userConfig = new UserConfig.Builder()
            .setUserId("UID")
            .setUserName("USER NAME")
            .setServerId("SERVER ID")
            .setUserTags("pay1,s1,vip2")
            .setCustomData(customData.toString())
            .setSyncCrmInfo(true)
            .build();
    AIHelpSupport.updateUserInfo(userConfig);
}

Language #

ELvaChatServiceSdk.setSDKLanguage("zh_CN");
AIHelpSupport.updateSDKLanguage("zh_CN");