🤖 API SamaBot v1

Intégrez SamaBot dans votre site, app ou plateforme

📑 Sommaire

🚀 Intégration rapide (3 méthodes) 💬 Widget JavaScript 🔌 API REST 📦 SDK JavaScript 💡 Exemples concrets 🔒 Sécurité & CORS 📝 Guide WordPress dédié →

🚀 Intégration rapide

1. Lien direct (le plus simple)

Partagez votre lien de chat partout (WhatsApp, Instagram, email...) :

https://api.samabot.app/chat/VOTRE_BOT_ID

2. Widget flottant (bulle de chat sur votre site)

Collez ce code juste avant </body> sur n'importe quel site :

<script> window.SamaBotConfig = { botId: 'VOTRE_BOT_ID', couleur: '#00c875' }; </script> <script src="https://api.samabot.app/widget.js" async></script>
✅ Compatible avec WordPress, Shopify, Wix, React, Vue, HTML pur, etc.

3. iframe (intégration page complète)

<iframe src="https://api.samabot.app/chat/VOTRE_BOT_ID" width="100%" height="600" style="border:none;border-radius:12px"></iframe>

🔌 API REST publique

Base URL: https://api.samabot.app/api/v1

🔓 Tous les endpoints publics ont CORS ouvert (Access-Control-Allow-Origin: *) pour intégration depuis n'importe quel domaine.

📋 Récupérer les infos d'un bot

GET /api/v1/bots/:id
curl https://api.samabot.app/api/v1/bots/sargal-mov2odnz

Retourne : nom, logo, couleur, adresse, téléphone, horaires, livraison, paiement, etc.

🛍️ Récupérer le catalogue (produits/services)

GET /api/v1/bots/:id/catalogue
curl https://api.samabot.app/api/v1/bots/VOTRE_BOT_ID/catalogue

Retourne tous les produits avec photos, prix, descriptions, emojis. Idéal pour afficher sur votre site

{ "bot": { "nom": "Sargal", "couleur": "#00c875" }, "catalogue": [ { "id": 0, "nom": "Pizza Margherita", "prix": 5000, "desc": "Sauce tomate, mozzarella, basilic", "photo": "https://...", "emoji": "🍕" } ], "count": 1, "livraison_frais": 1000, "paiement": { "wave": "+221...", "om": "+221..." } }

🛒 Créer une commande depuis votre site

POST /api/v1/bots/:id/commandes
curl -X POST https://api.samabot.app/api/v1/bots/VOTRE_BOT_ID/commandes \ -H "Content-Type: application/json" \ -d '{ "items": [{"nom":"Pizza","prix":5000,"qte":1}], "total": 6000, "client_nom": "Aminata", "client_tel": "+221771234567", "adresse_livraison": "Almadies" }'

✅ Crée la commande + envoie email/WhatsApp au patron + confirmation au client

💬 Envoyer un message au bot IA

POST /api/v1/bots/:id/chat
curl -X POST https://api.samabot.app/api/v1/bots/VOTRE_BOT_ID/chat \ -H "Content-Type: application/json" \ -d '{"message":"Bonjour, vos horaires?","sessionId":"client123"}'

⭐ Récupérer les avis

GET /api/v1/bots/:id/avis?limit=20

Idéal pour social proof sur votre site

🎁 Valider un code promo

POST /api/v1/bots/:id/promo/validate
curl -X POST https://api.samabot.app/api/v1/bots/VOTRE_BOT_ID/promo/validate \ -H "Content-Type: application/json" \ -d '{"code":"BIENVENUE10","total":6000}'

📊 Statistiques publiques

GET /api/v1/bots/:id/stats

Note moyenne, nombre d'avis, nombre de messages traités

📦 SDK JavaScript (le plus rapide)

Inclus le SDK puis utilisez l'API simplifiée :

<script src="https://api.samabot.app/sdk.js"></script> <script> const sb = SamaBot('VOTRE_BOT_ID'); // Récupérer le catalogue const cat = await sb.getCatalogue(); console.log(cat.catalogue); // Envoyer un message au bot IA const r = await sb.sendMessage('Vos horaires?'); console.log(r.reply); // Créer une commande const cmd = await sb.createOrder({ items: [{nom:'Pizza',prix:5000}], total: 6000, client_nom: 'Aminata', client_tel: '+221771234567' }); // Valider un code promo const promo = await sb.validatePromo('BIENVENUE10', 6000); if (promo.valid) console.log('-' + promo.reduction + ' FCFA'); </script>

💡 Exemples concrets

Exemple 1 : Afficher votre catalogue sur votre site WordPress

<div id="mon-catalogue">Chargement...</div> <script src="https://api.samabot.app/sdk.js"></script> <script> const sb = SamaBot('VOTRE_BOT_ID'); sb.getCatalogue().then(d => { const html = d.catalogue.map(p => `<div class="produit"> <h3>${p.emoji} ${p.nom}</h3> <p>${p.desc||''}</p> <strong>${p.prix.toLocaleString('fr-FR')} FCFA</strong> <a href="https://api.samabot.app/chat/VOTRE_BOT_ID?produit=${p.id}">Commander</a> </div>` ).join(''); document.getElementById('mon-catalogue').innerHTML = html; }); </script>

Exemple 2 : Bouton "Avis" avec note moyenne

<script src="https://api.samabot.app/sdk.js"></script> <script> SamaBot('VOTRE_BOT_ID').getStats().then(s => { document.getElementById('rating').innerHTML = '⭐ ' + s.avg_rating + ' (' + s.total_reviews + ' avis)'; }); </script>

Exemple 3 : App React

// catalogue.jsx import { useState, useEffect } from 'react'; function Catalogue() { const [produits, setProduits] = useState([]); useEffect(() => { fetch('https://api.samabot.app/api/v1/bots/VOTRE_BOT_ID/catalogue') .then(r => r.json()) .then(d => setProduits(d.catalogue)); }, []); return produits.map(p => <div key={p.id}>{p.nom}: {p.prix} F</div>); }

🔒 Sécurité & CORS

Endpoints publics (CORS *)

Tous les endpoints /api/v1/bots/:id/* ont CORS ouvert et sont consultables depuis n'importe quel domaine sans authentification.

Limitations

EndpointLimite
GET /catalogueIllimité (mise en cache navigateur)
POST /chat30 messages/min/IP (selon plan)
POST /commandes10 commandes/min/IP
POST /promo/validate60/min/IP

Bonnes pratiques

Questions? Contactez-nous