Android USSD Dialer with Webhook Integration

Job ID: 38794661

Budget: $250 – $750 USD

I'm looking for an experienced Android developer who can create a USSD dialer for us.

Project Overview

The Android USSD Dialer application is designed to execute USSD codes on an Android device automatically, based on requests received from a webhook. The app enables users to create and manage macros for various USSD-based services (e.g., checking balance, sending money via bKash, Nagad,easypaisa,jazzcash) and execute them with specified parameters.

Key Requirements:
- Proficient in Android development
- Experience with USSD application development
- Knowledge in webhook integration
- Understanding of user authentication systems


Key Features:
 • Webhook Integration: Executes USSD requests based on webhook requests.
 • Device Pairing: Pairs the app with an Android device using a unique device ID and API key.
 • Secure API Key Usage: Each API key is linked to a single device, preventing unauthorized usage.
 • Macro Support: Users can define multiple macros for different USSD actions.
 • USSD Response Handling: Captures the last response of the USSD session and sends it back via an HTTP request.

System Architecture:

Components
 1. Android Application:
 • Listens for webhook requests.
 • Executes USSD codes based on defined macros.
 • Captures USSD session responses.
 • Sends captured responses back to a specified HTTP endpoint.
 2. Webhook Server:
 • Receives HTTP POST requests with parameters for the USSD macro.
 • Validates the request using the API key and device ID.
 3. Backend API:
 • Manages API keys and device pairing.
 • Provides endpoints for webhook integration and device pairing.

Data Flow
 1. Webhook server receives a request with macro details.
 2. The server validates the API key and device pairing.
 3. If valid, the Android app executes the USSD macro.
 4. The app captures the final USSD response and sends it back to the specified callback URL.

Requirements:

Android App
 • Minimum Android Version: Android 7.0 (Nougat) or higher
 • Permissions:
 • CALL_PHONE: To dial USSD codes.
 • READ_PHONE_STATE: To access device information for pairing.
 • INTERNET: For webhook and callback requests.

Backend API
 • Endpoints:
 • /pair-device: Pairs an API key with a device ID.
 • /webhook/:api_key: Handles incoming webhook requests.
 • /callback: Receives captured USSD responses.

API Design:
1. Device Pairing Endpoint

URL: /api/pair-device
Method: POST

Request Body:

{
  "device_id": "android_device_id",
  "api_key": "unique_api_key"
}

Response:

{
  "status": "success",
  "message": "Device paired successfully."
}

2. Webhook Endpoint

URL: /api/webhook/:api_key
Method: POST

Request Body:

{
  "phone_no": "01728737373",
  "amount": "500",
  "pin": "63627",
  "macro_name": "bkash",
  "callback_url": "https://example.com/callback"
}

Response:

{
  "status": "initiated",
  "message": "USSD request initiated."
}

3. Callback Endpoint

URL: /api/callback
Method: POST

Request Body:

{
  "device_id": "android_device_id",
  "ussd_response": "Your transaction of 500 BDT is successful."
}

Response:

{
  "status": "success",
  "message": "Response received."
}

Macro Configuration

Users can define custom macros for different USSD operations using the following format.

Example Macro

Macro Name: bkash

Initiator Code: *247#

Steps:
 1. 1 (Select “Send Money” option)
 2. {phone_no} (Receiver’s phone number)
 3. {amount} (Amount to send)
 4. {pin} (User’s PIN)

Macro Definition:

{
  "name": "bkash",
  "initiator": "*247#",
  "steps": [
    "1",
    "{phone_no}",
    "{amount}",
    "{pin}"
  ]
}

Execution Flow

 1. The app dials *247#.
 2. It navigates through the steps using the parameters provided in the webhook request.
 3. Captures the final response and sends it to the callback URL.

Security Considerations:

 • API Key Validation: Each API key is tied to a single device ID to prevent unauthorized usage.
 • SSL/TLS: All webhook and callback requests should use HTTPS to ensure data privacy.
 • Input Sanitization: Validate and sanitize inputs to prevent USSD injection attacks.

Error Handling:

The Android app and backend API will handle the following errors:
 1. Invalid API Key: If the API key does not match the paired device.
• Response: {"status": "error", "message": "Invalid API key."}
 2. USSD Execution Error: If the USSD session fails or is interrupted.
 • Response: {"status": "error", "message": "USSD execution failed."}
 3. Timeout Error: If the USSD session takes longer than expected.
 • Response: {"status": "error", "message": "USSD session timeout."}

Implementation Plan

 1. Phase 1: Backend API Development
 • Create endpoints for device pairing, webhook handling, and callback response.
 • Set up API key management and validation.
 2. Phase 2: Android App Development
 • Develop the Android app with USSD dialer functionality.
 • Implement webhook request handling and response callback.
 3. Phase 3: Macro Feature Integration
 • Allow users to define and manage macros.
 • Integrate macro execution with USSD dialing.
 4. Phase 4: Testing and QA
 • Test USSD execution with different telecom operators.
 • Ensure security and performance standards are met.

Conclusion

This project aims to simplify USSD-based operations via an automated Android application paired with secure webhook requests. By providing flexible macro definitions and secure API key management, it enables seamless and automated interactions with USSD services like bKash and Nagad, making it suitable for financial transactions, balance checks, and other telecom services.