mTrakr API Documentation

Base Url

http://smsprocessing-morphtech.boxfuse.io

SMS API

The SMS API is responsible for processing the raw SMS request into meaningful transction.

Endpoint

POST :  http://smsprocessing-morphtech.boxfuse.io/processmessages

Headers

    Content-Type    :   application/json
    Signature       :   signatureKey

Request Json

[
    {
        "body"      : String,
        "sender"    : String,   (Optional)
        "time"      : Long,     (Optional)
        "userId"    : String    (Optional)
    }
]

API Fields Detail

    body    :   Body of the SMS to be processed.
    sender  :   Sender of the SMS to be processed.
    time    :   Time the SMS was received.
    userId  :   Unique Id of every user in your application.

Sample Payload

[
    {
        "sender": "121",
        "body": "Bill Details For 9876543210: Bill Date: 06-MAY-2017 Prev.Due: Rs 630.74 This Month's Due Rs 929.79 Tot. Due: Rs 929.53 Due Date: 24-MAY-2017 Delivery Date: 11-May-2017 To view bill details or to pay online, click www.airtel.in/ccm/?p=m",
        "time": 1491146382416
    },
    {
        "sender": "DM-HDFCBK",
        "body": "Rs.2000.00 was withdrawn using your HDFC Bank Card ending 1414 on 2017-04-02:10:50:09 at +YBL C AVENUE RD. Avl bal: Rs.74778.99",
        "time": 1491124095000
    },
    {
        "sender": "AD-SBICRD",
        "body": "E-statement dated 02/06/2017 has been sent on your registered email ID. Total amt due of Rs 29215 or Min Amt of Rs 13167 is payable by 22/06/2017",
        "time": 1491124095000
    }
]

Sample Response

[
  {
    "bills": {
      "name": "airtel",
      "billAmount": 929.79,
      "billType": "MOBILE",
      "paid": false,
    },
    "sms": {
      "body": "Bill Details For 7503200832: Bill Date: 06-MAY-2017 Prev.Due: Rs 630.74 This Month's Due Rs 929.79 Tot. Due: Rs 929.53 Due Date: 24-MAY-2017 Delivery Date: 11-May-2017 To view bill details or to pay online, click www.airtel.in/ccm/?p=m",
      "sender": "121",
      "time": 1491146382416,
      "requestId": "bf71cdd9-13c2-499e-b7d1-2629284cb61d"
    }
  },
  {
    "transaction": {
      "bank": "hdfc",
      "accountNum": "1414",
      "amount": 2000,
      "txnType": "ACCOUNT_DEBIT",
      "balance": 74778.99,
      "txnTime": 1491124095000,
      "txnMode": "ATM_WITHDRAWAL",
      "beneficiary": "+YBL C AVENUE RD."
    },
    "sms": {
      "body": "Rs.2000.00 was withdrawn using your HDFC Bank Card ending 1414 on 2017-04-02:10:50:09 at +YBL C AVENUE RD. Avl bal: Rs.74778.99",
      "sender": "DM-HDFCBK",
      "time": 1491124095000,
      "requestId": "bf71cdd9-13c2-499e-b7d1-2629284cb61d"
    }
  },
  {
    "statements": {
      "dueDate": 0,
      "minAmount": 13167,
      "dueAmount": 29215,
      "bank": "sbi",
      "paid": false
    },
    "sms": {
      "body": "E-statement dated 02/06/2017 has been sent on your registered email ID. Total amt due of Rs 29215 or Min Amt of Rs 13167 is payable by 22/06/2017",
      "sender": "AD-SBICRD",
      "time": 1491124095000,
      "requestId": "bf71cdd9-13c2-499e-b7d1-2629284cb61d"
    }
  }
]

User Profiling API (Coming Soon)

The user profiling API creates a profile of the user based on the list of SMS given.

Endpoint

http://smsprocessing-morphtech.boxfuse.io/profile/

Headers

  Content-Type  : application/json
  Signature   : signatureKey

Request Json

[
  {
    "body"    : String,
    "sender"  : String,   (Optional)
    "time"    : Long,   (Optional)
    "userId"  : String  (Optional)
  }
]

API Fields Detail

  body  : Body of the SMS to be processed.
  sender  :   Sender of the SMS to be processed.
  time  :   Time the SMS was received.
  userId  :   Unique Id of every user in your application.

Sample Payload

[
    {
      "sender": "121",
      "body": "Bill Details For 9876543210: Bill Date: 06-MAY-2017 Prev.Due: Rs 630.74 This Month's Due Rs 929.79 Tot. Due: Rs 929.53 Due Date: 24-MAY-2017 Delivery Date: 11-May-2017 To view bill details or to pay online, click www.airtel.in/ccm/?p=m",
      "time": 1491146382416
    },
    {
      "sender": "DM-HDFCBK",
      "body": "Rs.2000.00 was withdrawn using your HDFC Bank Card ending 1414 on 2017-04-02:10:50:09 at +YBL C AVENUE RD. Avl bal: Rs.74778.99",
      "time": 1491124095000
    },
    {
      "sender": "AD-SBICRD",
      "body": "E-statement dated 02/06/2017 has been sent on your registered email ID. Total amt due of Rs 29215 or Min Amt of Rs 13167 is payable by 22/06/2017",
      "time": 1491124095000
    }
    .
    .
    .
    .
    .
    .
    .
    .
    .
    .
]

Sample Response

{
    "userId": "99b999ac-8c53-49fe-916d-775351d6c2e9",
    "txn": {
        "smsTxn": 903,
        "manualTxn": 0,
        "creditCardTxn": 153,
        "debitCardTxn": 86,
        "atmTxn": 73,
        "merchant": " Amazon, Flipkart, Lenskart, 365 WHOLE FOODS , YO, YO CHINA ....... ",
        "bank": ", airtelmoney, axis, corpbk, hdfc, icici, idbi, indus, paytm, sbi",
        "transactionMode": "ATM_REVERSAL, ATM_WITHDRAWAL, BALANCE_CHECK, BANK_CHARGES, CHEQUE_DEBIT, CREDIT_CARD_EXPENSE, CREDIT_CARD_REVERSAL, DEBIT_CARD_EXPENSE, E_WALLET_CREDIT, E_WALLET_DEBIT, IMPS_CREDIT, IMPS_DEBIT, INT_CREDIT, NEFT_INWARD, NEFT_OUTWARD, NET_BKG_DEBIT, OTHER_CREDIT, OTHER_DEBIT, SALARY_CREDIT"
    },
    "createdTs": 1499419298531,
    "eWalletTransactionCount": 10,
    "eWalletBankList": "airtelmoney,paytm",
    "totalCreditCardTransactionExpenses": 128733.63,
    "bankTransactionsTotalAmount": 13386677.64,
    "totalAtmWithdrawalTransactionAmount": 313700,
    "totalUpiTransactions": 7,
    "netInflowAmount": 6276642.87,
    "netOutflowAmount": 7110780.77,
    "mostPreferredDebitMode": "CREDIT_CARD_EXPENSE",
    "mostPreferredCreditMode": "IMPS_CREDIT",
    "totalExpenseAmount": 617998.59,
    "totalDebitTransactions": 586,
    "totalCreditTransactions": 149,
    "avgCreditCardTxnAmount": 1316.13,
    "avgDebitCardTxnAmount": 1013.68,
    "avgAtmWithdrawalAmount": 4297.26
}

Android SDK Integration - Process SMS

The android SDK let's you process user's SMS and give you a financially meaningful output from them on your android app.

Add these lines in your top level build.gradle of the app

  allprojects {
      repositories {
        jcenter()
        maven{
            credentials{
              username = 'username'
              password = 'password'
            }
            url "http://ec2-35-154-126-236.ap-south-1.compute.amazonaws.com/artifactory/libs-release-local"
        }
      }
    }

Add following lines in your app level build.gradle file

  compile 'com.n2tech.mtrakr.sdk:trakr-sdk:1.0.0@aar'
  compile 'com.google.android.gms:play-services-location:11.0.1'

Add following permission to your app's manifest (note : make sure you are taking care of asking these permissions from user)

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

Initialize and start reading the sms on your app

/**
 * Initializes the application
 * Call this method in onCreate of your app
 *
 * @param application application
 * @param whiteDrawableIcon white drawable icon resource id for displaying in notification
 * @param signature provided by us
 */

TrakrInitializer.initialize(
  Application application,
  int whiteDrawableIcon,          
  String signature
)

To get output data, create a BroadcastReceiver and extend it from UserProfileReceiver and implement the required methods.

for example

public class UserDataReceiver extends UserProfileReceiver {
  public static String TAG = UserDataReceiver.class.getSimpleName();

  @Override
  public void onProfileReceive(Context context, JSONArray txnArray) {
    Log.e(TAG, txnArray.toString()); // json array of user's bills, statements and transactions
  }

  @Override
  public void onError(Context context, String error) {
    Log.e(TAG, error);
  }
}

Register the above created reciver in manifest file

<receiver android:name=".UserDataReceiver">
  <intent-filter>
    <action android:name="com.n2tech.mtrakr.USER_PROFILE_RECEIVED" />
  </intent-filter>
</receiver>

Sample Payload for Process SMS

[
    {
        "sender": "121",
        "body": "Bill Details For 9876543210: Bill Date: 06-MAY-2017 Prev.Due: Rs 630.74 This Month's Due Rs 929.79 Tot. Due: Rs 929.53 Due Date: 24-MAY-2017 Delivery Date: 11-May-2017 To view bill details or to pay online, click www.airtel.in/ccm/?p=m",
        "time": 1491146382416
    },
    {
        "sender": "DM-HDFCBK",
        "body": "Rs.2000.00 was withdrawn using your HDFC Bank Card ending 1414 on 2017-04-02:10:50:09 at +YBL C AVENUE RD. Avl bal: Rs.74778.99",
        "time": 1491124095000
    },
    {
        "sender": "AD-SBICRD",
        "body": "E-statement dated 02/06/2017 has been sent on your registered email ID. Total amt due of Rs 29215 or Min Amt of Rs 13167 is payable by 22/06/2017",
        "time": 1491124095000
    }
]

Sample Response for Process SMS

[
  {
    "bills": {
      "name": "airtel",
      "billAmount": 929.79,
      "billType": "MOBILE",
      "paid": false,
    },
    "sms": {
      "body": "Bill Details For 7503200832: Bill Date: 06-MAY-2017 Prev.Due: Rs 630.74 This Month's Due Rs 929.79 Tot. Due: Rs 929.53 Due Date: 24-MAY-2017 Delivery Date: 11-May-2017 To view bill details or to pay online, click www.airtel.in/ccm/?p=m",
      "sender": "121",
      "time": 1491146382416,
      "requestId": "bf71cdd9-13c2-499e-b7d1-2629284cb61d"
    }
  },
  {
    "transaction": {
      "bank": "hdfc",
      "accountNum": "1414",
      "amount": 2000,
      "txnType": "ACCOUNT_DEBIT",
      "balance": 74778.99,
      "txnTime": 1491124095000,
      "txnMode": "ATM_WITHDRAWAL",
      "beneficiary": "+YBL C AVENUE RD."
    },
    "sms": {
      "body": "Rs.2000.00 was withdrawn using your HDFC Bank Card ending 1414 on 2017-04-02:10:50:09 at +YBL C AVENUE RD. Avl bal: Rs.74778.99",
      "sender": "DM-HDFCBK",
      "time": 1491124095000,
      "requestId": "bf71cdd9-13c2-499e-b7d1-2629284cb61d"
    }
  },
  {
    "statements": {
      "dueDate": 0,
      "minAmount": 13167,
      "dueAmount": 29215,
      "bank": "sbi",
      "paid": false
    },
    "sms": {
      "body": "E-statement dated 02/06/2017 has been sent on your registered email ID. Total amt due of Rs 29215 or Min Amt of Rs 13167 is payable by 22/06/2017",
      "sender": "AD-SBICRD",
      "time": 1491124095000,
      "requestId": "bf71cdd9-13c2-499e-b7d1-2629284cb61d"
    }
  }
]

Push notifications(Coming soon)

Send targeted push notifications from mtrakr Dashboard and check all the insights about the conversion of notifications

Add rules to your root-level build.gradle, to include the google-services plugin

buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

Add dependencies to build.gradle file


compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'

Apply google-services plugin by adding this at the bottom of your app-level build.gradle


// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

Register your app to receive push notifications

<service android:name="com.n2tech.mtrakr.sdk.fcm.MyFcmListenerService">
  <intent-filter>
    <action android:name="com.google.firebase.MESSAGING_EVENT"/>
  </intent-filter>
</service>

<service android:name="com.n2tech.mtrakr.sdk.fcm.MyInstanceIDListenerService">
  <intent-filter>
    <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
  </intent-filter>
</service>

Handle notification clicks Create a broadcast receiver by extending it from PushNotificationReceiver and implement onNotificationClick method e.g.

public class NotificationReceivedEvent extends PushNotificationReceiver {

  @Override public void onNotificationClick(Context context) {

      // handle your click events here or navigate your activity

  }
}

register your receiver in manifest

  <receiver android:name=".NotificationReceiver">
      <intent-filter>
        <action android:name="com.n2tech.mtrakr.notificationClickAction" />
      </intent-filter>
  </receiver>