Webhooks Webhooks
Send real-time event notifications to your own server whenever something happens in your Mugib project. أرسل إشعارات الأحداث الفورية لخادمك الخاص عندما يحدث شيء ما في مشروع مجيب.
Webhooks let you build real-time integrations. Instead of polling Mugib for updates, your server receives an HTTP POST the moment an event occurs — a new chat message, a session created, a KB update, and more.
Available Events
- 💬
chat.message— a user sent a message - 🤖
chat.response— the bot replied - 🆕
session.created— a new conversation started - ⚠️
quota.warning— you're approaching your usage limit - 🚫
quota.exceeded— your usage limit was reached - 📚
kb.updated— a knowledge base entry was added or changed - ⚙️
tenant.updated— project settings were modified
Adding a Webhook
- Open your project → Webhooks in the sidebar
- Click Add Webhook
- Enter your Endpoint URL — a publicly accessible HTTPS URL on your server
- Select one or more events to subscribe to
- Optionally add an HMAC Secret to verify payloads (recommended)
- Add a Description for your own reference
- Click Create
Testing a Webhook
On any webhook card, click the ⚡ icon to Send Test Payload. Mugib sends a sample event to your endpoint and shows you:
- ✅ Success / ❌ Failed
- HTTP status code returned
- Round-trip time in milliseconds
- Response body (first 500 characters)
Use this to confirm your server is receiving and responding correctly before relying on it in production.
Delivery Logs
Click the 🕐 icon on any webhook card to view Delivery Logs. Each log entry shows:
- Which event triggered it
- HTTP status code from your server
- Response time
- Success ✅ or failure ❌
If there are failed deliveries, click Retry Failed to resend the last failed payload.
Verifying Payloads (HMAC)
When you add an HMAC Secret, Mugib signs every payload with SHA-256 and includes the signature in the X-Mugib-Signature header. On your server, verify it like this:
// Node.js example
const crypto = require('crypto');
const signature = req.headers['x-mugib-signature'];
const expected = crypto
.createHmac('sha256', YOUR_SECRET)
.update(JSON.stringify(req.body))
.digest('hex');
if (signature !== expected) return res.status(401).send('Invalid'); Reject any request that fails verification — it wasn't sent by Mugib.
تُتيح Webhooks بناء تكاملات فورية. بدلاً من الاستفسار المتكرر من مجيب عن التحديثات، يستقبل خادمك HTTP POST في اللحظة التي يحدث فيها حدث — رسالة دردشة جديدة، جلسة مُنشأة، تحديث قاعدة معرفة، والمزيد.
الأحداث المتاحة
- 💬
chat.message— مستخدم أرسل رسالة - 🤖
chat.response— البوت ردّ - 🆕
session.created— محادثة جديدة بدأت - ⚠️
quota.warning— تقترب من حد الاستخدام - 🚫
quota.exceeded— تجاوزت حد الاستخدام - 📚
kb.updated— إدخال قاعدة معرفة أُضيف أو غُيّر - ⚙️
tenant.updated— إعدادات المشروع عُدّلت
إضافة Webhook
- افتح مشروعك ← Webhooks في الشريط الجانبي
- انقر إضافة Webhook
- أدخل Endpoint URL — رابط HTTPS متاح للعموم على خادمك
- اختر حدثاً واحداً أو أكثر للاشتراك فيه
- اختيارياً أضف HMAC Secret للتحقق من الحمولات (موصى به)
- أضف وصفاً لمرجعك الخاص
- انقر إنشاء
اختبار Webhook
على أي بطاقة webhook، انقر أيقونة ⚡ لـإرسال حمولة اختبارية. يُرسل مجيب حدثاً نموذجياً لنقطة نهايتك ويُظهر:
- ✅ نجح / ❌ فشل
- كود HTTP المُعاد
- وقت الرحلة الكاملة بالميلي ثانية
- جسم الرد (أول 500 حرف)
سجلات التسليم
انقر أيقونة 🕐 على أي بطاقة webhook لعرض سجلات التسليم. يُظهر كل سجل: الحدث الذي أطلقه، كود HTTP، وقت الاستجابة، ونتيجة النجاح أو الفشل.
إذا كانت هناك تسليمات فاشلة، انقر إعادة المحاولة الفاشلة لإعادة إرسال آخر حمولة فاشلة.
التحقق من الحمولات (HMAC)
عند إضافة HMAC Secret، يوقّع مجيب كل حمولة بـ SHA-256 ويضمّن التوقيع في header الـ X-Mugib-Signature. على خادمك، تحقق منه هكذا:
// مثال Node.js
const signature = req.headers['x-mugib-signature'];
const expected = crypto
.createHmac('sha256', YOUR_SECRET)
.update(JSON.stringify(req.body))
.digest('hex');
if (signature !== expected) return res.status(401); ارفض أي طلب يفشل في التحقق — لم يُرسَل من مجيب.
Ready to build your AI agent?
Start your free trial and put what you've learned into practice.
Start Free Trial