Skip to main content

NoBox.Ai Chat Python SDK (nobox-chat-sdk)

Official Python Client SDK and Real-time Webhook Receiver Application for NoBox.Ai Omnichannel Platform Integration.

🔗 GitLab Repository: https://gitlab.ubig.co.id/erik/nobox-chat-python


🐍 Preview Aplikasi Demo & Interactive Console Inspector

Package ini menyediakan solusi Python SDK lengkap (dukungan Python 3.7+) yang dilengkapi dengan Service REST API, Webhook HMAC-SHA256 Verifier & Parser, serta Flask Web Application & Interactive Traffic Inspector bawaan untuk mempermudah debugging dan integrasi platform NoBox.Ai.


📦 Instalasi & Dependensi

Opsi A: Instalasi via PyPI / Pip

pip install nobox-chat-sdk

Atau instalasi langsung dari Git Repository:

pip install git+https://gitlab.ubig.co.id/erik/nobox-chat-python.git

Opsi B: Import Library di Kode Python

from nobox_chat import NoboxChat

# Inisialisasi SDK
nb = NoboxChat(base_url="https://id.nobox.ai/", app_name="NoBoxChatPython", app_version="1.0.0")

✨ Fitur Utama

  • 🔑 Autentikasi Native Python: Login ke NoBox.Ai REST API untuk memperoleh Bearer Token secara otomatis.
  • 📋 Chatrooms & Messages Manager: Service intuitif untuk mengambil daftar percakapan, channel, akun WhatsApp terhubung, serta riwayat pesan.
  • 📤 Fast Message Dispatcher & Media Upload: Mengirim pesan teks dan konversi attachment base64 ke URL media secara langsung.
  • 🔐 Webhook HMAC-SHA256 Verifier & Event Parser: Verifikasi keamanan signature X-Nobox-Signature-256 dan parsing event payload otomatis (TerimaPesan, TerimaAck, TerimaRead).
  • 📊 AppInfo & Metadata Tracking: Melacak header metadata X-App-Name: NoBoxChatPython dan X-App-Version: 1.0.0 pada setiap request API.

📂 Struktur Repositori

nobox-chat-python/
├── setup.py                      # Konfigurasi PyPI Package Installer
├── requirements.txt              # Dependensi Python (requests, flask)
├── README.md                     # Dokumentasi Resmi Python SDK
├── nobox_chat.py                # Core Python SDK Library (`NoboxChat`)
├── app.py                        # Flask Web Application & Webhook Receiver
├── templates/
│   └── index.html                # Frontend Web UI Demo
└── static/                       # Custom CSS/JS Static Assets

📖 Panduan Penggunaan Python SDK (NoboxChat)

1. Autentikasi & Generate Token

from nobox_chat import NoboxChat

nb = NoboxChat()

# Login untuk mendapatkan Bearer token
result = nb.generate_token("user@example.com", "password")

if not result["IsError"]:
    token = result["Data"]
    print("Token Berhasil Didapatkan:", token)
else:
    print("Gagal Login:", result["Error"])

2. Mengambil Daftar Percakapan & Riwayat Chat

# 1. Ambil 20 Percakapan Teratas
chatrooms = nb.fetch_chatrooms(take=20)
print("Daftar Chatroom:", chatrooms["Data"])

# 2. Ambil Riwayat Pesan berdasarkan Room ID
messages = nb.fetch_messages(room_id="ROOM_ID_123", take=50)
print("Riwayat Pesan:", messages["Data"])

3. Mengirim Pesan Teks & Media via REST API

# 1. Mengirim Pesan Teks
send_res = nb.send_message(
    ext_id="628123456789",
    channel_id=1,
    account_id="744927678136325",
    text="Halo dari Python SDK NoBox.Ai!"
)

# 2. Upload Attachment Base64
with open("photo.jpg", "rb") as f:
    import base64
    b64_data = base64.b64encode(f.read()).decode("utf-8")

upload_res = nb.upload_base64_to_file({
    "media": {
        "filename": "photo.jpg",
        "mimetype": "image/jpeg",
        "data": b64_data
    }
})

4. Webhook Verification & Event Handler

from nobox_chat import NoboxChat

# Verifikasi & Parse Payload Webhook HMAC-SHA256
try:
    event_data = NoboxChat.handle_webhook(
        payload_body=raw_json_body,
        signature_header=request_headers.get("X-Nobox-Signature-256"),
        webhook_secret="YOUR_WEBHOOK_SECRET",
        throw_error=True
    )
    print("Webhook Valid! Event:", event_data)
except ValueError as e:
    print("Webhook Invalid:", str(e))

🌐 Menjalankan Flask Application Demo secara Lokal

Untuk menjalankan aplikasi demo Web UI & Webhook receiver lokal:

pip install -r requirements.txt
python app.py

Buka browser Anda di: http://localhost:5001 atau http://127.0.0.1:5001.


📄 Lisensi

Proyek ini dirilis di bawah lisensi MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nobox_chat_sdk-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nobox_chat_sdk-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file nobox_chat_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: nobox_chat_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for nobox_chat_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2b680ecee13039d46b840238643598a044641a0c8578b87e7b094466cdf6c921
MD5 5e17eb5aadbde4086b2f991890a8fa7c
BLAKE2b-256 3376ab734314052cb9925b79438e0a2dfc36b744fcf0c83bfaddacba8027bab6

See more details on using hashes here.

File details

Details for the file nobox_chat_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: nobox_chat_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.10

File hashes

Hashes for nobox_chat_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b83e5286e6a1d994dfdeefe74641ce226bfdb3fd85d8c92c52dd08b04d38819c
MD5 54fb0dc8565d9943f390f70caa0d0513
BLAKE2b-256 9857129357f3f7c18c2025fa917cf2624053010785a9b9cccacbd92ed2b64ac5

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1

2 files

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page