Deep Linking into Brand Messenger Legacy in Android Apps

Learn about deep linking in Brand Messenger Legacy on Android

Deep linking is an excellent way to bring the end users into Brand Messenger Legacy in your mobile application. You can also transfer information from the link to the resulting message sent by the user.

So for example, if you send a link to messaging in your mobile app in response to a user on another channel - Facebook Messenger, Twitter DM, or other Messaging channel, you can move the conversation into a channel you own in your app.

At a minimum, we recommend including the conversation ID and agent ID into the app deep link URL.

To deep link into your app, you'll create the URL and then add code in the app to read the data passed and send it along as metadata. (We'll show an example of this later on.)

A deep link URL uses a format like the following where PROVIDER is the name you have set for the host application provider, such as abc for Apple Business Chat or fb for Facebook Messenger and the key/value pairs include whatever data you want to parse from the provider to Brand Messenger Legacy.

{YOUR_APP_URL_SCHEME}://PROVIDER?parameter_key={parameter_value}&....

📘

Your Implementation Advisor can help with the initial configuration of the URL scheme on the web portal and walk you through how the template can be sent as part of the response.

This example deep link URL passes the conversation ID and agent ID.

rocksnropes://fb?conversationDisplayId={conversation.id}&conversationAssignedAgentId={agent.uuid}

When the end user taps on the deep link, your brand app opens and shows the conversation view controller.

To configure the deep link, first add an appropriate deep linking schema to the Androidmanifest.xml of the app. Here is an example:

<activity ...>
   <intent-filter android:label="@string/rocks_and_ropes_deeplink">
       <action android:name="android.intent.action.VIEW" />
       <category android:name="android.intent.category.DEFAULT" />
       <category android:name="android.intent.category.BROWSABLE" />
       <data android:scheme="rocksnropes"
           android:host="fb" />
   </intent-filter>
</activity>

To read all the values and send it to the backend as metadata, add the following:

Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();

if (action.equals(Intent.ACTION_VIEW) && data != null) {
   String conversationId = data.getQueryParameter("conversationDisplayId");
   String agentId = data.getQueryParameter("conversationAssignedAgentId");
   User user = User.getCurrentUser();
   Map<String, Object> userProperties = new HashMap<>();
   userProperties.put("conversationId", conversationId);
   userProperties.put("agentId", agentId);
   user.addProperties(userProperties);
   ConversationActivity.show(this);
}