SDK API Reference

With the Android SDK, you can customize the behavior of your chat bot by configuring initial chat settings, either in XML or programmatically using the AdaEmbedView.Settings class.

1<!-- Example 1: XML -->
2<support.ada.embed.widget.AdaEmbedView
3 android:id="@+id/ada_chat_frame"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 app:ada_handle="ada-example"
7 app:ada_cluster="ca"
8 app:ada_language="en"
9 app:ada_handle="ada-example"
10 app:ada_greeting="5c59aaabd8269e0339979014"/>

Settings

The Ada Android SDK supports the following settings.

cluster

app:ada_cluster="ca" or .cluster("ca")

Specifies the Kubernetes cluster to be used. You should not need to change this value, unless directed by an Ada team member.

greeting

app:ada_greeting="5c59aaabd8269e0339979014" or .greeting("5c59aaabd8269e0339979014")

Use to customize the greeting messages that new chatters see. This is useful for setting view-specific greetings across your app. The greeting should correspond to the ID of the Answer you would like to use, which you can find in the URL of the corresponding Answer in the dashboard.

Example

handle

app:ada_handle="my-bot" or adaSettings = AdaEmbedView.Settings.Builder("my-bot")

The handle for your bot. This is a required field.

language

app:ada_language="en" or .language("en")

Takes in a language code to programatically set the bot language. You must first turn languages on in your Ada dashboard.

Language codes use the ISO 639-1 language format.

metaFields

Use metaFields to pass information about a chatter to Ada. This can be useful for tracking information about your customers, as well as personalizing their experience. For example, you may wish to track the phone_number and name for conversation attribution. (See Variables for more information.)

Once set, you can access this information:

  • in the email attachment from Handoff Form submissions
  • via the Meta variables modal in the Conversations page of your Ada dashboard
Kotlin
1 .metaFields(
2 AdaEmbedView.MetaFields.Builder()
3 .setField("name", "John")
4 .setField("age", 20)
5 .setField("authorized", true)
6 )

You can also set metaFields using XML. For this, you need to create a JSON file in the res/raw directory, and set the reference to the view declaration.

To change these values after bot setup, use the setMetaFields action.

sensitiveMetaFields

Use this parameter to pass sensitive meta information about a chatter. This works like metafields but the values are not stored in the database and will be deleted after 24 hours. To change these values after bot setup, use the setSensitiveMetafields action.

zdChatterAuthCallback

Use the zdChatterAuthCallback to request a JWT token from your API, then pass it to Ada. This creates shared trust between Ada and Zendesk, and in turn allows for verifiable chatter identity.

To implement, define zdChatterAuthCallback on adaView or adaDialog, as in the following examples.

Using AdaEmbedView

Kotlin
1adaView.zdChatterAuthCallback = {
2 getToken() // this functions returns String
3}

Using AdaEmbedDialog

Kotlin
1val adaDialog = AdaEmbedDialog()
2adaDialog.zdChatterAuthCallback = {
3 getToken() // this functions returns String
4}

zdChatterAuthCallback is available only for Zendesk Chat. It is not available for Zendesk Messaging.

Actions

Use the actions below in conjunction with settings to customize the behavior of your bot in an Android app.

Note that the following actions apply to AdaEmbedView (see Launch Ada). To call actions in AdaEmbedActivity or AdaEmbedDialog, refer to these instructions.

deleteHistory

Kotlin
1adaView.deleteHistory()

Deletes the chatter used to fetch conversation logs for a chatter from storage. When a user opens a new chat window, a new chatter is generated.

To do this you also need to call deleteHistory() in your AdaEmbedView instance.

reset

Creates a new chatter and refreshes the chat window. To do this, call reset() in your AdaEmbedView instance.

Kotlin
1adaView.reset()

Reset can also take three optional parameters to be changed for the new chatter: language, metaFields, and greeting:

Kotlin
1val metaFields = AdaEmbedView.MetaFields.Builder()
2 .setField("name", "John")
3 .setField("age", 20)
4 .setField("authorized", true))
5val sensitiveMetaFields = AdaEmbedView.MetaFields.Builder()
6 .setField("name", "John")
7 .setField("age", 20)
8 .setField("authorized", true))
9adaView.reset(language = "fr", metaFields = metaFields, sensitiveMetaFields = sensitiveMetaFields)

setLanguage

setLanguage(languageCode: string)

Changes the language in chat programatically. Use this action, rather than the language setting, to change the chat language without clearing the chat history. Language codes must use a lowercase, two-letter code, in ISO 639-1 language format. For example, en, fr, ca, ar, and so on.

adaView.setLanguage("fr")

Before using setLanguage:

  • You must turn languages on in your Ada dashboard.

  • The chat window must be opened at least once.

setMetaFields

The Android SDK allows you to change your metaFields while the chat frame is open. To do this, call setMetaFields() in your AdaEmbedView instance, and pass your new metaFields as an argument:

Kotlin
1val metaFields = AdaEmbedView.MetaFields.Builder()
2 .setField("name", "John")
3 .setField("age", 20)
4 .setField("authorized", true))
5adaView.setMetaFields(metaFields)

setSensitiveMetaFields

The Android SDK allows you to change your sensitiveMetaFields while the chat frame is open. To do this, call setSensitiveMetaFields() in your AdaEmbedView instance and pass your new sensitiveMetaFields as an argument:

Kotlin
1val sensitiveMetaFields = AdaEmbedView.MetaFields.Builder()
2 .setField("name", "John")
3 .setField("age", 20)
4 .setField("authorized", true))
5adaView.setSensitiveMetaFields(sensitiveMetaFields)

triggerAnswer

adaView.triggerAnswer(answerId: string)

Triggers an answer in chat. Include the Answer ID, which you can find in the URL of the corresponding Answer in the dashboard.

Example

adaView.triggerAnswer("627d28a9bd9ca9e5337b9763")

The chat window must be opened at least once before this method can be used.

AdaEmbedActivity and AdaEmbedDialog

To call actions in the AdaEmbedActivity, you must first create your own activity that inherits AdaEmbedActivity. Then using the getAdaView() you can obtain the AdaEmbedView instance.

Kotlin
1// AdaEmbedActivity
2class MyCustomActivity : AdaEmbedActivity(){
3 override fun onResume() {
4 super.onResume()
5 val adaView = getAdaView()
6 adaView.setMetaFields(
7 AdaEmbedView.MetaFields.Builder()
8 .setField("name", "John")
9 .setField("age", 20)
10 .setField("authorized", true))
11 adaView.setSensitiveMetaFields(
12 AdaEmbedView.MetaFields.Builder()
13 .setField("top", "secret")
14 .setField("id", 20)
15 .setField("isUser", true))
16 adaView.deleteHistory()
17 adaView.reset()
18 }
19}

To call actions in the AdaEmbedDialog, you can obtain AdaEmbedDialog instance from FragmentManager:

Kotlin
1// AdaEmbedDialog
2val adaDialog = supportFragmentManager.findFragmentByTag(AdaEmbedDialog.TAG) as AdaEmbedDialog
3adaDialog.setMetaFields(
4 AdaEmbedView.MetaFields.Builder()
5 .setField("name", "John")
6 .setField("age", 20)
7 .setField("authorized", true))
8adaDialog.setSensitiveMetaFields(
9 AdaEmbedView.MetaFields.Builder()
10 .setField("top", "secret")
11 .setField("id", 20)
12 .setField("isUser", true))
13adaDialog.deleteHistory()
14adaDialog.reset()