Skip to main content

Askribe Android SDK

Askribe Android SDK enables you to show questionnaire directly from your own mobile app.

SDK integration (Requires API level 21+)

Setup

Download the sample project which contains the Kotlin library in library folder.

The SDK needs access to Network to fetch and display the questionnaires. For this, add the following two permissions in your AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

When using blocks which require camera / microphone, add appropriate permissions to your manifest

<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.MICROPHONE" />
<uses-feature android:name="android.hardware.audio.low_latency" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-feature android:name="android.hardware.audio.pro" />
<uses-feature android:name="android.hardware.microphone" />

Obtain the API key required to connect with Askribe servers from the Settings section in your Askribe dashboard.

Initialize the SDK with the key obtained from the above step.

AskribeSDK.init("<API-KEY>")

Embed survey in your app

Embed the questionnaire in your Activity by using calling AskribeSDK.showQuestionnaire(context, askribeParams, exit).

See the below section for a discussion on params

Params

Context

  • Type: AppCompatActivity
  • Required

AskribeParams has the following fields:

  • askribeKey
    • Type: String
    • Required
    • Obtain the API key required to connect with Askribe servers from the Settings section in your Askribe flow dashboard.
  • configId
    • Type: String
    • Required
  • context
    • Type: Map<String, VariableData>
    • Optional
    • Description: Pass a list of Key-Value pairs to be substituted in the flow
  • receiversEmailAddress
    • Type: String
    • Required if distributionType is AUTO_EMAIL
  • receiversPhoneNumber
    • Type: String
    • Required if distributionType is one of AUTO_SMS | AUTO_WHATSAPP | AUTO_VOICE
  • slackUserId
    • Type: String
    • Required if distributionType is AUTO_SLACK
  • webPushConfig
    • Type: ContactWebPushConfig
    • Required if distributionType is AUTO_PUSH_NOTIFICATION
  • androidPushConfig
    • Type: ContactAndroidPushConfig
    • Required if distributionType is AUTO_ANDROID_PUSH_NOTIFICATION
  • iOSPushConfig
    • Type: ContactIOSPushConfig
    • Required if distributionType is AUTO_IOS_PUSH_NOTIFICATION
  • language
    • Type: String
    • Optional
    • Description: Use this parameter to set the language of the flow

Exit

  • Type: (() -> Unit)
  • Optional
data class VariableData(
var contextVariableType: ContextVariableType? = null,
var value: String? = null,
)
data class CategoryValue(
var label: String? = null,
var value: String? = null,
)
data class ContextVariableType(
var variableType: VariableType? = null,
var categoryValues: List<String>? = null,
var nluEntityId: String? = null,
var blueprintId: String? = null,
var t1Type: ContextVariableType? = null,
var t2Type: ContextVariableType? = null,
)
enum class VariableType private constructor(internal var variableType: String) {
STRING("STRING"),
INTEGER("INTEGER"),
REAL("REAL"),
BOOLEAN("BOOLEAN"),
DATE("DATE"),
TIME("TIME"),
DATE_TIME("DATE_TIME"),
IMAGE("IMAGE"),
VIDEO("VIDEO"),
CATEGORY("CATEGORY"),
NLU_ENTITY("NLU_ENTITY"),
BLUEPRINT("BLUEPRINT"),
LIST("LIST"),
HASHMAP("HASHMAP"),
}
data class ContactAndroidPushConfig(
var fcmId: String? = null
)
data class ContactWebPushConfig(
var urlEndpoint: String? = null
var key: String? = null
var auth: String? = null
)
data class ContactIOSPushConfig(
var apnsId: String? = null
)

Integrating Push Notifications

To setup push notifications for your app:

  • Register for push notifications - Register for push notifications by calling AskribeSDK.setupPushNotifications(context: Context, cdpId: String)
  • Enrich the contact, optionally - You can enrich the contact created in the above step by calling AskribeSDK.enrichContact(context: Context, contactEnrichmentDTO: ContactEnrichmentDTO)
  • Check the sample app - Check the sample app to see how to do custom configuration for notification clicks, action items, etc.

ContactEnrichmentDTO has the following properties:

var email: String? = null; // Email Id of the user
var phone: String? = null; // Phone Number of the user
var app: String? = null; // Name of your app
var appUserId: String? = null; // Id of the user in your app
var customFieldValues: Map<String, String> = mapOf(); // Values for predefined custom fields
var cdpId: String? = null; // ID of the cdp where you want to enrich the contact. This field is mandatory