Modules

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.

Conversation #

Scenes:

If the user is not logged in, pull up the robot customer service to show the user a log-in related story line, and always display the entrance to contact the human in the upper right corner of the page;

If the user is logged in, contact the manual customer service directly for the user and display the welcome message of the manual customer service based on the user name.

private void showSupport(boolean isLogin, String userName) {
    if (isLogin) {
        ELvaChatServiceSdk.showElva("user_name", "user_id", "server_id", "1");
    } else {
        HashMap<String, Object> map = new HashMap();
        HashMap<String, Object> config = new HashMap();
        config.put("elva-custom-metadata", map);
        map.put("private_wel_message", "How can we help you, " + userName + "?");
        map.put("anotherWelcomeText", "LoginIssues");
        ELvaChatServiceSdk.showConversation("user_id", "server_id", config);
    }
}

Thanks to the extraction of part of the logic of user data update, now you can implement the above scenarios with clearer logic:

private void showSupport(boolean isLogin, String userName) {
    ConversationConfig.Builder builder = new ConversationConfig.Builder();
    if (isLogin) {
        builder.setConversationIntent(ConversationIntent.HUMAN_SUPPORT)
                .setWelcomeMessage("How can we help you, " + userName + "?");
    } else {
        builder.setConversationIntent(ConversationIntent.BOT_SUPPORT)
                .setStoryNode("LoginIssues")
                .setAlwaysShowHumanSupportButtonInBotPage(true);
    }
    AIHelpSupport.showConversation(this, builder.build());
}

FAQ #

Scenes:

If the user is not logged in, after the user thinks that a certain FAQ is not helpful, he/she can click the contact customer service entry on the FAQ details page to pull up the robot customer service, and directly contact the human in the robot customer service;

If the user is logged in, he/she can directly contact the manual customer service by clicking the entry on any page of the FAQ, and display the manual customer service welcome message according to the user name.

private void showFAQs(boolean isLogin, String userName) {
    HashMap<String, Object> map = new HashMap();
    HashMap<String, Object> config = new HashMap();
    config.put("elva-custom-metadata", map);

    if (isLogin) {
        config.put("showContactButtonFlag", "1");
        config.put("directConversation", "1");
        ELvaChatServiceSdk.showFAQs(config);
        map.put("private_wel_message", "How can we help you, " + userName + "?");
    } else {
        config.put("showConversationFlag", "1");
    }

    ELvaChatServiceSdk.showFAQs(config);
}

Naow you can implement the above scenarios with clearer logic:

private void showAllFAQSections(boolean isLogin, String userName) {
    ConversationConfig.Builder conversationBuilder = new ConversationConfig.Builder();
    FaqConfig.Builder faqConfigBuilder = new FaqConfig.Builder();
    
    if (isLogin) {
        conversationBuilder.setConversationIntent(ConversationIntent.HUMAN_SUPPORT)
                .setWelcomeMessage("How can we help you, " + userName + "?");
        faqConfigBuilder.setShowContactUsMoment(ShowContactUsMoment.ALWAYS)
                .setConversationConfig(conversationBuilder.build());
    } else {
        conversationBuilder.setConversationIntent(ConversationIntent.BOT_SUPPORT)
                .setAlwaysShowHumanSupportButtonInBotPage(true);
        faqConfigBuilder.setShowContactUsMoment(ShowContactUsMoment.AFTER_MARKING_UNHELPFUL)
                .setConversationConfig(conversationBuilder.build());
    }
    
    AIHelpSupport.showAllFAQSections(faqConfigBuilder.build());
}

Operation #

Scenes:

If the user is not logged in, the robot customer service will be displayed for the user, and the first tab will be displayed by default;

If the user is logged in, display manual customer service for the user, and set the customer service title of the operation module to the user name;

Displaying manual customer service directly in the opration module is not supportive in 1.x version.

private void showOPList(boolean isLogin, String userName) {
    ELvaChatServiceSdk.showElvaOP(userName, "user_id", "server_id", "1");
}
private void showOperation(boolean isLogin, String userName) {
    OperationConfig.Builder opConfigBuilder = new OperationConfig.Builder();

    if (isLogin) {
        ConversationConfig.Builder conversationBuilder = new ConversationConfig.Builder();
        conversationBuilder.setConversationIntent(ConversationIntent.HUMAN_SUPPORT);
        opConfigBuilder.setSelectIndex(Integer.MAX_VALUE)
                .setConversationTitle(userName)
                .setConversationConfig(conversationBuilder.build());
    } else {
        opConfigBuilder.setSelectIndex(0);
    }

    AIHelpSupport.showOperation(opConfigBuilder.build());
}