Whatsapp Banking Api

This document explains how your business can integrate with StroWallet WhatsApp Banking Api using a shared WhatsApp number. StroWallet handles WhatsApp delivery; you only handle menus and logic.


StroWallet owns the WhatsApp number

Customers chat with WhatsApp (BankBot)

StroWallet routes messages to your webhook

Your API returns menu responses

StroWallet sends the reply back to the customer

You do NOT integrate with WhatsApp directly.

Customer
↓ WhatsApp
StroWallet (BankBot)
↓ Webhook (POST JSON)
Your Server
↓ JSON reply
StroWallet
↓ WhatsApp reply
Customer


You must expose a public HTTPS endpoint.

Example
POST https://yourdomain.com/webhooks/whatsappbot

📥 Incoming Webhook Request

StroWallet will send a POST JSON request to your webhook.

Headers
Content-Type: application/json
Accept: application/json

Payload Example
{
"event": "whatsapp.inbound",
"from": "+2348011111111",
"to": "whatsapp:+16593005060",
"message": "menu",
"selected_tenant": 1,
"timestamp": "2025-12-14T21:40:00Z"
}

Field Description
Field Description
event Always whatsapp.inbound
from Customer WhatsApp number (E.164)
to StroWallet WhatsApp number
message User’s message text
selected_tenant Your tenant ID
timestamp ISO timestamp

📤 Expected Webhook Response

Your API MUST return JSON with a reply key.

✅ Correct Response
{
"reply": "🏦 Welcome!\n1️⃣ Check Balance\n2️⃣ Send Money\n3️⃣ Buy Airtime"
}

StroWallet will convert this to WhatsApp message automatically.

❌ Invalid Responses (DO NOT)

❌ HTML
❌ Plain text
❌ Empty response
❌ XML

📋 Menu Standards (Recommended)

Use numbered menus for best UX.

Main Menu Example
Welcome to MyBank 👋

1️⃣ Check Balance
2️⃣ Send Money
3️⃣ Buy Airtime
4️⃣ Buy Data
5️⃣ My Account

Reply with a number.

🧾 Sample Command Handling (Tenant Logic)
Balance

User sends:

1

You respond:

{
"reply": "💰 Balance: ₦25,430.50\nReply MENU to continue."
}

Standalone PHP WhatsApp Banking Webhook

/**

  • Standalone WhatsApp Banking Webhook (Tenant)
  • Compatible with StroWallet BankBot
    */

header('Content-Type: application/json');

// Read raw input
$raw = file_get_contents('php://input');
$data = json_decode($raw, true);

// Basic validation
if (!$data || !isset($data['from'], $data['message'])) {
echo json_encode([
'reply' => 'Invalid request.'
]);
exit;
}

$from = trim($data['from']); // +234801xxxxxxx
$message = strtolower(trim($data['message']));

// -------------------------------------------------
// VERY SIMPLE SESSION (for demo only)
// In production, use Redis / DB
// -------------------------------------------------
session_id(md5($from));
session_start();

$state = $_SESSION['state'] ?? 'menu';

// -------------------------------------------------
// MENU HANDLING
// -------------------------------------------------
if ($message === 'menu' || $state === 'menu') {
$_SESSION['state'] = 'awaiting_choice';

echo json_encode([
    'reply' =>
        "🏦 *Welcome to DemoBank*\n\n" .
        "1️⃣ Check Balance\n" .
        "2️⃣ Send Money\n" .
        "3️⃣ Buy Airtime\n" .
        "4️⃣ Buy Data\n" .
        "5️⃣ My Account\n\n" .
        "Reply with a number."
]);
exit;

}

// -------------------------------------------------
// MAIN OPTIONS
// -------------------------------------------------
if ($state === 'awaiting_choice') {

switch ($message) {

    // CHECK BALANCE
    case '1':
        $_SESSION['state'] = 'menu';
        echo json_encode([
            'reply' => "💰 *Your Balance*\nNGN 25,430.50\n\nReply MENU to continue."
        ]);
        exit;

    // SEND MONEY
    case '2':
        $_SESSION['state'] = 'send_money';
        echo json_encode([
            'reply' =>
                "💸 *Send Money*\n" .
                "Send like this:\n\n" .
                "`5000 0123456789 058`\n\n" .
                "(amount account bankcode)"
        ]);
        exit;

    // BUY AIRTIME
    case '3':
        $_SESSION['state'] = 'airtime';
        echo json_encode([
            'reply' =>
                "📱 *Buy Airtime*\n" .
                "Send like this:\n\n" .
                "`1000 08031234567`"
        ]);
        exit;

    // BUY DATA
    case '4':
        $_SESSION['state'] = 'data';
        echo json_encode([
            'reply' =>
                "🌐 *Buy Data*\n" .
                "Send like this:\n\n" .
                "`MTN 2GB 08031234567`"
        ]);
        exit;

    // MY ACCOUNT
    case '5':
        $_SESSION['state'] = 'menu';
        echo json_encode([
            'reply' =>
                "👤 *My Account*\n" .
                "Name: John Doe\n" .
                "Phone: {$from}\n" .
                "Status: Active\n\n" .
                "Reply MENU to continue."
        ]);
        exit;

    default:
        echo json_encode([
            'reply' => "❌ Invalid option.\nReply MENU to start again."
        ]);
        exit;
}

}

// -------------------------------------------------
// SEND MONEY FLOW
// -------------------------------------------------
if ($state === 'send_money') {

$parts = explode(' ', $message);

if (count($parts) !== 3) {
    echo json_encode([
        'reply' => "❌ Invalid format.\nUse: `5000 0123456789 058`"
    ]);
    exit;
}

[$amount, $account, $bank] = $parts;

$_SESSION['state'] = 'menu';

echo json_encode([
    'reply' =>
        "✅ *Transfer Successful*\n" .
        "₦{$amount} sent to {$account}\n\n" .
        "Reply MENU to continue."
]);
exit;

}

// -------------------------------------------------
// AIRTIME FLOW
// -------------------------------------------------
if ($state === 'airtime') {

$parts = explode(' ', $message);

if (count($parts) !== 2) {
    echo json_encode([
        'reply' => "❌ Invalid format.\nUse: `1000 08031234567`"
    ]);
    exit;
}

[$amount, $phone] = $parts;

$_SESSION['state'] = 'menu';

echo json_encode([
    'reply' =>
        "✅ *Airtime Sent*\n" .
        "₦{$amount} sent to {$phone}\n\n" .
        "Reply MENU to continue."
]);
exit;

}

// -------------------------------------------------
// DATA FLOW
// -------------------------------------------------
if ($state === 'data') {

$_SESSION['state'] = 'menu';

echo json_encode([
    'reply' =>
        "✅ *Data Purchase Successful*\n" .
        "Your data has been activated.\n\n" .
        "Reply MENU to continue."
]);
exit;

}

// -------------------------------------------------
// FALLBACK
// -------------------------------------------------
$_SESSION['state'] = 'menu';

echo json_encode([
'reply' => "❌ I didn’t understand that.\nReply MENU to start."
]);