Contacto SDK clients require devices running Android 10 or higher.
Sign in to your Contacto account as an Administrator. Navigate to Channels > Chat, select the Chat App to be integrated, and navigate the Code tab to access the APP ID and App Key.
Add the Contacto SDK dependency to the root build.gradle (project/build.gradle)
implementation("com.contacto:contacto-android:1.0.3")
implementation 'com.contacto:contacto-android:1.0.3'
Code snippets to add Contacto SDK using other dependency managers are available here.
Invoke ContactoClient.init() with your APP ID and APP KEY before invoking/ using any feature of Contacto SDK.
import com.contacto.consumer.android.ContactoClient
import com.contacto.consumer.android.ui.model.User
appId = "{{APP ID of the Chat App}}", // Access the APP ID from the Contacto Console (https://console.contacto.com)
appKey = "{{APP Key of the Chat App}}" // Access the APP Key from the Contacto Console (https://console.contacto.com)
ContactoClient.init(appId = appId, appKey = appKey)
import com.contacto.consumer.android.ContactoClient
import com.contacto.consumer.android.ui.model.User
appId = "{{APP ID of the Chat App}}", // Access the APP ID from the Contacto Console (https://console.contacto.com)
appKey = "{{APP Key of the Chat App}}" // Access the APP Key from the Contacto Console (https://console.contacto.com)
ContactoClient.INSTANCE.init(appId, appKey);
You can send basic user information at any point to give you more context on the user when your support agents are messaging back and forth with them.
val user = User(
firstName = {{User's first name}},
lastName = {{User's last name}},
phoneNumber = "{{User's phone number}}",
email = "{{User's email address}}"
)
User user = new User(
{{User's first name}},
{{User's last name}},
"{{User's phone number}}",
"{{User's email address}}"
);
ContactoClient.loadChat(this, user)
ContactoClient.INSTANCE.loadChat(this, user);
import com.contacto.consumer.android.utility.Constants
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == Constants.ERROR_CODE) {
String error = data.getStringExtra(Constants.PARAM_ERROR);
Snackbar.make(binding.root, error, Snackbar.LENGTH_SHORT).show();
}
}
The repository contains sample apps to familiarize you with the Contacto Android SDK. You can re-use the code available here in your own Apps. Each example in this project is a stand-alone Android app, capable of being run independently through Gradle or Android Studio.
The current list of samples apps are:
-
A demo app showcasing the initiation of chat conversation with the click of a
Chat with Us
button.
We welcome contributions of any kind including new examples, bug fixes, and documentation improvements. We recommend opening an issue describing what you want to build so that we can discuss how to move forward if it is a major change. For minor changes such as typo fixes and one-liners, go ahead and open a pull request.
Please submit bug reports to Contacto.