Brand Messenger Android SDK Conversation (APAC)

Learn how to initiate chat with an agent in the Brand Messenger Android SDK

Initiate Chat with Agent

For starting the messaging activity, using the following script:

BrandMessengerManager.show(context);
BrandMessengerManager.show(context);

If the environment is also configured with Welcome-Messages, the following can be used instead of show(context). This will also send an API request to give the user a welcome-message.

BrandMessengerManager.showWithWelcome(context);

To just send the welcome-message API request without displaying the conversation screen, use the following

BrandMessengerManager.sendWelcomeMessageRequest(context);

Intercept Message Actions

Message actions from SDK conversation screen, such as user tapping on link-buttons, can be intercepted and handled outside of the SDK via a delegate.

BrandMessengerManager.setMessageActionDelegate(new KBMMessageActionDelegate() {
    @Override
    public boolean onAction(Context context, String action, Message message, Object object, Map<String, Object> replyMetadata) {
        switch (action) {
            // Example action types
            case KBMRichMessage.SUBMIT_BUTTON:
                break;
            case KBMRichMessage.QUICK_REPLY:
                break;
            case KBMRichMessage.TEMPLATE_ID + 9:
                break;
            case KBMRichMessage.WEB_LINK:
                // URL link data is in object.url.
                openUrl(((KBMRichMessageModel.KBMPayloadModel)object).getUrl());
                return true;
        }
        // Return false to let SDK handle action. True if action is handled here.
        return false;
    }
});
BrandMessengerManager.setMessageActionDelegate( object : KBMMessageActionDelegate {
    override fun onAction(
        context: Context?,
        action: String?,
        message: Message?,
        `object`: Any?,
        replyMetadata: MutableMap<String, Any>?
    ): Boolean {
        when (action) {
            KBMRichMessage.SUBMIT_BUTTON -> return false
            KBMRichMessage.QUICK_REPLY -> return false
            KBMRichMessage.TEMPLATE_ID -> return false
            KBMRichMessage.WEB_LINK -> {
                // handle link.
                return true
            }
        }
        return false;
    }
})

Did this page help you?