{
 "name": "منشیوا — گزارش روزانهٔ تماس‌ها",
 "nodes": [
  {
   "parameters": {
    "content": "## گزارش روزانه\nهر روز ساعت ۲۰ تماس‌های همان روز را از منشیوا می‌خواند و یک متن فارسی آماده می‌سازد (`text`).\n۱) در گرهٔ «تماس‌ها» کلید API را بگذارید (دسترسی «خواندن» کافی است).\n۲) خروجی «خلاصه» را به تلگرام، بله یا ایمیل وصل کنید.\nمنطقهٔ زمانی گردش‌کار را روی Asia/Tehran بگذارید.",
    "width": 560,
    "height": 240
   },
   "id": "263fe3a9-2973-5ebc-b2b5-71cefc766f72",
   "name": "راهنما",
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1,
   "position": [
    -40,
    -300
   ]
  },
  {
   "parameters": {
    "rule": {
     "interval": [
      {
       "triggerAtHour": 20
      }
     ]
    }
   },
   "id": "17afbfb1-a105-5056-ae49-556e8e080410",
   "name": "هر روز ۲۰:۰۰",
   "type": "n8n-nodes-base.scheduleTrigger",
   "typeVersion": 1.2,
   "position": [
    0,
    0
   ]
  },
  {
   "parameters": {
    "url": "https://monshiva.com/api/public/v1/calls",
    "sendQuery": true,
    "queryParameters": {
     "parameters": [
      {
       "name": "status",
       "value": "all"
      }
     ]
    },
    "sendHeaders": true,
    "headerParameters": {
     "parameters": [
      {
       "name": "Authorization",
       "value": "Bearer PASTE_YOUR_KEY"
      }
     ]
    },
    "options": {}
   },
   "id": "d4dc6637-8a7b-58f4-bb8f-0e19dd6f05bf",
   "name": "تماس‌ها",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    220,
    0
   ]
  },
  {
   "parameters": {
    "jsCode": "// تماس‌های امروز (به وقت تهران) را خلاصه می‌کند\nconst calls = $input.first().json.calls || [];\nconst today = new Date(Date.now() + 3.5 * 3600 * 1000).toISOString().slice(0, 10);\n// گفتگوهایی که فقط باز شده‌اند و هیچ صحبتی در آن‌ها نشده کنار گذاشته می‌شوند\nconst mine = calls.filter(c => String(c.created || '').slice(0, 10) === today && (c.completed || c.transcript_available || c.summary));\nconst done = mine.filter(c => c.completed).length;\nconst cb = mine.filter(c => c.callback_requested).length;\nconst booked = mine.filter(c => c.booking).length;\nconst lines = mine.slice(0, 15).map(c => `• ${c.customer?.name || c.customer?.phone || 'ناشناس'}: ${(c.summary || '—').slice(0, 120)}`);\nconst text = `گزارش امروز منشیوا (${today})\\n${mine.length} تماس، ${done} کامل، ${booked} نوبت، ${cb} درخواست تماس\\n` + lines.join('\\n');\nreturn [{ json: { date: today, total: mine.length, completed: done, bookings: booked, callbacks: cb, text } }];"
   },
   "id": "ca1260a0-3c01-5b91-85d5-4ab879d0193c",
   "name": "خلاصه",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    440,
    0
   ]
  }
 ],
 "connections": {
  "هر روز ۲۰:۰۰": {
   "main": [
    [
     {
      "node": "تماس‌ها",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "تماس‌ها": {
   "main": [
    [
     {
      "node": "خلاصه",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "active": false,
 "settings": {
  "executionOrder": "v1",
  "timezone": "Asia/Tehran"
 },
 "pinData": {},
 "meta": {
  "templateCredsSetupCompleted": false
 }
}