api-config.json 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. {
  2. "name": "competitor-bsr-tracking",
  3. "displayName": "竞品BSR排名追踪",
  4. "description": "追踪竞品BSR/销量/价格变化趋势,生成增长路径分析和风险预警汇总",
  5. "category": "competitor-analysis",
  6. "version": "1.3.0",
  7. "type": "orchestration",
  8. "parameters": {
  9. "competitorAsins": {
  10. "type": "array",
  11. "items": {
  12. "type": "string"
  13. },
  14. "required": true,
  15. "description": "竞品ASIN列表"
  16. },
  17. "domain": {
  18. "type": "integer",
  19. "required": false,
  20. "default": 1,
  21. "description": "Amazon站点(1=美国)"
  22. }
  23. },
  24. "pipeline": [
  25. {
  26. "step": 1,
  27. "name": "批量获取竞品监控数据",
  28. "forEach": "competitorAsins",
  29. "api": {
  30. "service": "EcomDataService.getMonitorData",
  31. "endpoint": "/api/MonitorQuery",
  32. "method": "POST",
  33. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  34. "headers": {
  35. "Authorization": "Bearer {{vocToken}}"
  36. },
  37. "requestBody": {
  38. "ASIN": "${asin}"
  39. },
  40. "queryParams": {
  41. "domain": "${domain}"
  42. }
  43. },
  44. "output": "monitorData",
  45. "responseExtract": "{ PriceHistory, RankHistory, RatingHistory, ReviewCountHistory, SellerCount }"
  46. },
  47. {
  48. "step": 2,
  49. "name": "批量获取竞品当前状态",
  50. "forEach": "competitorAsins",
  51. "api": {
  52. "service": "EcomDataService.getProductDetail",
  53. "endpoint": "/api/ProductRequest",
  54. "method": "POST",
  55. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  56. "headers": {
  57. "Authorization": "Bearer {{vocToken}}"
  58. },
  59. "requestBody": {
  60. "ASIN": "${asin}",
  61. "Trend": 1,
  62. "QueryTrendStartDt": "",
  63. "QueryTrendEndDt": ""
  64. },
  65. "queryParams": {
  66. "domain": "${domain}"
  67. }
  68. },
  69. "output": "competitorDetails",
  70. "responseExtract": "{ Title, Brand, SalesPrice, Ratings, RatingsCount, BSR, MonthlySales, Category }"
  71. },
  72. {
  73. "step": 3,
  74. "name": "BSR/销量/价格趋势分析",
  75. "type": "compute",
  76. "logic": "analyzeTrends(monitorData, competitorDetails)",
  77. "algorithm": {
  78. "bsrTrend": "近7/14/30天BSR变化方向和幅度百分比",
  79. "salesTrend": "日销量/月销量趋势,环比增减百分比",
  80. "priceChange": "价格调整记录,是否在做促销",
  81. "ratingChange": "评分和评论数的变化趋势",
  82. "alerts": "识别异常变化: BSR大幅下降=销量暴涨, 突然降价=促销战"
  83. },
  84. "output": "tracking"
  85. },
  86. {
  87. "step": 4,
  88. "name": "增长路径分析",
  89. "type": "compute",
  90. "logic": "analyzeGrowthPath(tracking, competitorDetails)",
  91. "algorithm": {
  92. "tierClassification": "头部(Top10%)/腰部(10-40%)/尾部(40%+)",
  93. "dailySalesGap": "距上一层级门槛还差多少日销",
  94. "skuAdvice": "聚焦核心SKU打爆款建议",
  95. "keywordAdvice": "主攻长尾词提升排名建议"
  96. },
  97. "output": "growthPath"
  98. },
  99. {
  100. "step": 5,
  101. "name": "风险预警汇总",
  102. "type": "compute",
  103. "logic": "generateRiskAlerts(tracking, competitorDetails)",
  104. "algorithm": {
  105. "bsrRisk": "BSR连续下降检测",
  106. "ratingRisk": "评分下滑检测",
  107. "priceWarRisk": "价格战风险检测",
  108. "inventoryRisk": "库存风险推断",
  109. "complianceRisk": "合规风险检测"
  110. },
  111. "output": "riskAlerts"
  112. }
  113. ],
  114. "response": {
  115. "type": "object",
  116. "properties": {
  117. "tracking": {
  118. "type": "array",
  119. "description": "竞品追踪数据列表",
  120. "items": {
  121. "type": "object",
  122. "properties": {
  123. "asin": {
  124. "type": "string"
  125. },
  126. "brand": {
  127. "type": "string"
  128. },
  129. "currentBsr": {
  130. "type": "integer"
  131. },
  132. "bsrTrend": {
  133. "type": "object",
  134. "properties": {
  135. "7d": {
  136. "type": "number"
  137. },
  138. "14d": {
  139. "type": "number"
  140. },
  141. "30d": {
  142. "type": "number"
  143. }
  144. }
  145. },
  146. "salesTrend": {
  147. "type": "object",
  148. "properties": {
  149. "7d": {
  150. "type": "number"
  151. },
  152. "14d": {
  153. "type": "number"
  154. },
  155. "30d": {
  156. "type": "number"
  157. }
  158. }
  159. },
  160. "priceChange": {
  161. "type": "object",
  162. "properties": {
  163. "current": {
  164. "type": "number"
  165. },
  166. "previous": {
  167. "type": "number"
  168. },
  169. "changePercent": {
  170. "type": "number"
  171. }
  172. }
  173. },
  174. "ratingChange": {
  175. "type": "object",
  176. "properties": {
  177. "current": {
  178. "type": "number"
  179. },
  180. "previous": {
  181. "type": "number"
  182. },
  183. "newReviews": {
  184. "type": "integer"
  185. }
  186. }
  187. },
  188. "alerts": {
  189. "type": "array",
  190. "items": {
  191. "type": "object",
  192. "properties": {
  193. "type": {
  194. "type": "string"
  195. },
  196. "severity": {
  197. "type": "string"
  198. },
  199. "message": {
  200. "type": "string"
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. },
  208. "summary": {
  209. "type": "object",
  210. "properties": {
  211. "mostActive": {
  212. "type": "string"
  213. },
  214. "biggestThreat": {
  215. "type": "string"
  216. },
  217. "opportunityWindow": {
  218. "type": "string"
  219. }
  220. }
  221. },
  222. "growthPath": {
  223. "type": "object",
  224. "properties": {
  225. "currentTier": {
  226. "type": "string"
  227. },
  228. "nextTierThreshold": {
  229. "type": "object",
  230. "properties": {
  231. "dailySales": {
  232. "type": "integer"
  233. },
  234. "gap": {
  235. "type": "integer"
  236. }
  237. }
  238. },
  239. "skuAdvice": {
  240. "type": "string"
  241. },
  242. "keywordAdvice": {
  243. "type": "string"
  244. }
  245. }
  246. },
  247. "riskAlerts": {
  248. "type": "array",
  249. "items": {
  250. "type": "object",
  251. "properties": {
  252. "level": {
  253. "type": "string",
  254. "enum": [
  255. "high",
  256. "medium",
  257. "low"
  258. ]
  259. },
  260. "title": {
  261. "type": "string"
  262. },
  263. "description": {
  264. "type": "string"
  265. }
  266. }
  267. }
  268. }
  269. }
  270. },
  271. "timeout": 120000,
  272. "retry": {
  273. "maxAttempts": 2,
  274. "delay": 2000,
  275. "backoffMultiplier": 2
  276. },
  277. "tokenConfig": {
  278. "type": "bearer",
  279. "configFile": "~/.openclaw/voc-credentials.json",
  280. "tokenField": "vocToken",
  281. "resolutionOrder": [
  282. "configFile"
  283. ],
  284. "apigId": "7HwdQZk55B",
  285. "paymentUrlResolution": {
  286. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  287. "steps": [
  288. "1. 从 voc-credentials.json 获取当前 session token",
  289. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  290. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  291. "4. 将该URL展示给用户,引导扫码支付"
  292. ],
  293. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  294. "userResolveHeaders": {
  295. "X-Parse-Application-Id": "ncloudmaster",
  296. "X-Parse-Session-Token": "{vocToken}"
  297. },
  298. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  299. "paymentParams": {
  300. "user": "{resolvedUserId}",
  301. "apigid": "7HwdQZk55B",
  302. "fun_id": "HOkkX72PMF"
  303. },
  304. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  305. },
  306. "onMissing": {
  307. "action": "showPaymentQR",
  308. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  309. "title": "扫码开通 VOC-AI 数据服务",
  310. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  311. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  312. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  313. },
  314. "onBalanceInsufficient": {
  315. "action": "resolveUserThenShowPayment",
  316. "title": "VOC-AI Token 余额不足,请扫码充值",
  317. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  318. }
  319. },
  320. "errorHandling": {
  321. "balanceInsufficient": {
  322. "conditions": [
  323. {
  324. "responseField": "code",
  325. "operator": "in",
  326. "value": [
  327. -2,
  328. -3,
  329. -10,
  330. 402,
  331. 429
  332. ]
  333. },
  334. {
  335. "responseField": "msg",
  336. "operator": "contains",
  337. "value": [
  338. "余额不足",
  339. "insufficient",
  340. "balance",
  341. "quota",
  342. "没有开通",
  343. "权限或余额"
  344. ]
  345. },
  346. {
  347. "responseField": "mess",
  348. "operator": "contains",
  349. "value": [
  350. "余额不足",
  351. "insufficient",
  352. "balance",
  353. "quota",
  354. "没有开通",
  355. "权限或余额"
  356. ]
  357. },
  358. {
  359. "responseField": "message",
  360. "operator": "contains",
  361. "value": [
  362. "余额不足",
  363. "insufficient",
  364. "balance",
  365. "没有开通",
  366. "权限或余额"
  367. ]
  368. }
  369. ],
  370. "matchMode": "any",
  371. "trigger": "tokenConfig.onBalanceInsufficient"
  372. },
  373. "unauthorized": {
  374. "conditions": [
  375. {
  376. "responseField": "code",
  377. "operator": "in",
  378. "value": [
  379. 401,
  380. 403
  381. ]
  382. },
  383. {
  384. "responseField": "msg",
  385. "operator": "contains",
  386. "value": [
  387. "unauthorized",
  388. "token",
  389. "invalid",
  390. "auth"
  391. ]
  392. }
  393. ],
  394. "matchMode": "any",
  395. "trigger": "tokenConfig.onMissing"
  396. }
  397. }
  398. }