Webhook API
የሁለቱም ሞጁሎች እያንዳንዱ የwebhook መስመር፣ ከማረጋገጫ፣ ከጥያቄና ከምላሽ ቅርጾች ጋር።
ከታች ያሉት ሁሉም መስመሮች የሚጠሩት በውጫዊ ሲስተም (አብዛኛውን ጊዜ n8n) እንጂ በገባ ሰው አይደለም። auth='none' ይጠቀማሉ፤ ስለዚህ Odoo የመግቢያ ማረጋገጫ አያደርግም። በምትኩ እያንዳንዳቸው በጋራ የAPI ቁልፍ ያረጋግጣሉ።
ማረጋገጫ#
ቁልፉን በእያንዳንዱ ጥያቄ header ውስጥ ይላኩ፦
X-Api-Key: <the shared API key>
| ሁኔታ | ምላሽ |
|---|---|
| ቁልፉ ሲዛመድ | ጥያቄው ይቀጥላል። |
| ቁልፉ ሲጎድል ወይም ስህተት ሲሆን | 401 ከ {"error": "unauthorized"} ጋር። |
| በOdoo ውስጥ ምንም ቁልፍ አልተዋቀረም | 401. እያንዳንዱ ጥሪ ውድቅ ይደረጋል፣ AI Workforce ደግሞ ማስጠንቀቂያ ይመዘግባል። |
ንጽጽሩ በቋሚ ጊዜ ስለሚደረግ የምላሽ ጊዜ ቁልፉን አይገልጥም።
ጠንካራ ቁልፍ በዚህ ያመንጩ፦
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
Social Media Marketing Automation#
ቁልፉን በSocial Marketing → Configuration → Automation Settings ስር ያዋቅሩ (ሥራ አስኪያጆች (Manager) ብቻ)።
| ዘዴ | መስመር | ዓላማ |
|---|---|---|
GET | /social_media/webhook/posts/due | ቀናቸው ያለፈ Scheduled ልጥፎችን ይዘረዝራል። |
POST | /social_media/webhook/posts/<id>/result | የማተም ሙከራ ውጤትን ያሳውቃል። |
POST | /social_media/webhook/posts/<id>/ai-content | በAI የተመነጨ ይዘትን ያደርሳል። |
GET /social_media/webhook/posts/due#
ምላሽ 200፦
{
"posts": [
{
"id": 42,
"message": "We are excited to announce…",
"link_url": "https://example.com/launch",
"hashtags": ["ProductLaunch", "AcmeInc"],
"platform": "facebook",
"account_id": 3,
"account_handle": "@acme",
"campaign_id": 1,
"scheduled_date": "2026-05-01T09:00:00"
}
]
}
POST /social_media/webhook/posts/<id>/result#
የጥያቄ አካል (body)፦
{ "success": true, "like_count": 0, "comment_count": 0, "share_count": 0, "click_count": 0 }
ወይም በውድቀት ጊዜ፦
{ "success": false, "error": "Facebook API returned 190" }
- ሲሳካ ልጥፉ Published ይሆናል፣ Published Date ይሞላል፣ ስህተቱ ይጸዳል፣ ከአራቱ ቆጣሪዎች ያካተቷቸውም ሁሉ ይቀመጣሉ።
- ሳይሳካ ሲቀር ልጥፉ በላኩት
errorጽሑፍ Failed ይሆናል፤ ምንም ካልላኩ ደግሞ "n8n reported a publish failure." ይሆናል። - ምላሽ
200{"ok": true}፤ ለማይታወቅ ልጥፍ404{"error": "not_found"}።
POST /social_media/webhook/posts/<id>/ai-content#
የጥያቄ አካል (body)፦
{ "success": true, "message": "The drafted text", "hashtags": ["launch", "acme"] }
- ሲሳካ የልጥፉ AI Content Status Received ይሆናል። መልዕክት ከላኩ የልጥፉን ጽሑፍ ይተካል። እያንዳንዱ ሃሽታግ በስም ይፈለጋል (መጀመሪያ ያለው
#ይወገዳል)፣ ከሌለም ይፈጠራል፤ የልጥፉ ሃሽታጎች በዚያ ስብስብ ይተካሉ። - ሳይሳካ ሲቀር (
"success": false) ሁኔታው Failed ይሆናል፣ የላኩትerrorደግሞ በError Message ውስጥ ይቀመጣል። - ምላሽ
200{"ok": true}፤ ለማይታወቅ ልጥፍ404።
AI Growth Workforce#
ቁልፉን እንደ የሲስተም ግቤት social_media_ai_workforce.api_key ያዋቅሩ። የሲስተም ግቤቶች ይመልከቱ።
| ዘዴ | መስመር | ዓላማ |
|---|---|---|
GET | /social_ai/webhook/posts/due | ለማተም ዝግጁ የሆኑ በመርሐ ግብር የተያዙ ልጥፎች። |
POST | /social_ai/webhook/posts/<id>/content | በAI የተመነጨ ጽሑፍን ያደርሳል። |
POST | /social_ai/webhook/posts/<id>/result | የማተም ውጤትን ያሳውቃል። |
GET /social_ai/webhook/posts/due#
ቀናቸው ያለፈ እስከ 50 የሚደርሱ Scheduled ልጥፎች። ምላሽ 200፦
{
"count": 1,
"posts": [
{
"id": 42,
"name": "Launch teaser",
"message": "…",
"hashtags": "#SmartERP #Ethiopia",
"scheduled_date": "2026-05-01 09:00:00",
"agent": "AI Social Media Manager",
"platforms": { "telegram": true, "facebook": false, "instagram": false, "twitter": true }
}
]
}
ከሌላው ሞጁል ያሉትን ልዩነቶች ልብ ይበሉ፦ hashtags አንድ string ነው፣ platforms ደግሞ ከአንድ platform ይልቅ የባንዲራዎች (flags) ካርታ ነው።
POST /social_ai/webhook/posts/<id>/content#
የጥያቄ አካል (body)፦
{ "success": true, "message": "The drafted text", "hashtags": ["launch", "acme"] }
hashtagsዝርዝር (list) ሊሆን ይችላል (እያንዳንዱ ንጥል#ከሌለው ይጨመርለታል፣ በክፍተት ይያያዛሉ) ወይም string።messageከጎደለ400{"error": "missing 'message' in body"}ይመለሳል። (successካልተላከ ነባሪው true ነው።)- ሲሳካ የልጥፉ መልዕክት (እና ሃሽታጎች) ይተካሉ፣ AI Generated ይሞላል፣ AI Content Content Received ይሆናል፣ እንዲሁም ረቂቁ በሰው ለመገምገም ዝግጁ መሆኑን የሚያሳይ የእንቅስቃሴ መዝገብ ግቤት ይጻፋል። ምላሽ
{"status": "applied", "post_id": 42}። - በ
"success": falseሁኔታው Generation Failed ይሆናል፣ የላኩትerrorደግሞ ይቀመጣል። ምላሽ{"status": "recorded_failure"}። - ለማይታወቅ ልጥፍ
404{"error": "post not found"}።
POST /social_ai/webhook/posts/<id>/result#
የጥያቄ አካል (body)፦
{ "success": true, "detail": "Facebook post 123" }
ወይም፦
{ "success": false, "error": "Token expired" }
- ሲሳካ ልጥፉ Posted ይሆናል፣ Published ይመዘገባል፤
detailእንደ ውጤቱ ይቀመጣል። - ሳይሳካ ሲቀር ልጥፉ Failed ይሆናል፣ Failure Reason ይቀመጣል፣ Publish Failed ይመዘገባል።
- ምላሽ
{"status": "recorded", "post_id": 42}፤ ለማይታወቅ ልጥፍ404።
ማስጠንቀቂያ
የresult መስመር የልጥፉን ሁኔታ በማንኛውም ሁኔታ ላይ ቢሆን ወደ Posted ወይም Failed ይቀይራል፤ ከOdoo ውጭ ለሚደረግ ማተምም የማተም በር (publishing gate) አይሠራም። n8n እንዲያትማቸው የሚፈቅዱት በdue መስመር የተመለሱትን ልጥፎች ብቻ ያድርጉ፤ እነዚህም ሰው በመርሐ ግብር ያስያዛቸው ልጥፎች ናቸው።
ከcommand line መጥራት#
curl -s https://smarterp.example.com/social_ai/webhook/posts/due \
-H "X-Api-Key: $KEY"
SmartERP ወደ n8n የሚያደርጋቸው ጥያቄዎች#
አንድ ሰው Generate with AI ሲጫን SmartERP JSON ን ወደተዋቀረው webhook URL POST ያደርጋል፤ በ10 እስከ 15 ሰከንድ ውስጥ የስኬት ምላሽ ይጠብቃል። ረቂቁን ግን አይጠብቅም፦ n8n ወዲያውኑ ይመልሳል፣ ውጤቱን ደግሞ ቆይቶ በcallback URL ያደርሳል። የስህተት ሁኔታ ወይም ምላሽ አለመኖር ለተጠቃሚው ይገለጻል። AI Growth Workforce ደግሞ በልጥፉ ላይ እንደ ውድቀት ይመዘግበዋል፣ እንዲሁም 200፣ 201 ወይም 202 ብቻ እንደ ስኬት ይቀበላል።
| ሞጁል | የጊዜ ገደብ | የpayload መስኮች |
|---|---|---|
| Social Media Marketing Automation | 10 ሰከንድ | post_id, platform, account_handle, brief, callback_url, api_key |
| AI Growth Workforce | 15 ሰከንድ | post_id, brief, hashtags, agent, platforms, callback_url, api_key |
callback_url የሚገነባው ከOdoo web.base.url የሲስተም ግቤት ነው። ወደ የእርስዎ ይፋዊ HTTPS አድራሻ ያዘጋጁት፤ አለበለዚያ n8n ሊደርስበት የማይችል URL ይሰጠዋል።