api-config.json 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. {
  2. "name": "competitor-pricing-analysis",
  3. "displayName": "竞品定价策略分析",
  4. "description": "分析竞品定价策略,包括5分位价格带分布、黄金价格带评分、毛利估算、促销建议和盈亏平衡销量分析",
  5. "category": "competitor-analysis",
  6. "version": "1.3.0",
  7. "type": "orchestration",
  8. "parameters": {
  9. "categoryKeyword": {
  10. "type": "string",
  11. "required": true,
  12. "description": "品类关键词"
  13. },
  14. "competitorAsins": {
  15. "type": "array",
  16. "items": {
  17. "type": "string"
  18. },
  19. "required": true,
  20. "description": "竞品ASIN列表"
  21. },
  22. "ownPrice": {
  23. "type": "number",
  24. "required": false,
  25. "description": "自身产品当前价格,用于对比定位"
  26. },
  27. "domain": {
  28. "type": "integer",
  29. "required": false,
  30. "default": 1,
  31. "description": "Amazon站点(1=美国)"
  32. }
  33. },
  34. "pipeline": [
  35. {
  36. "step": 1,
  37. "name": "搜索品类Top100产品价格数据",
  38. "api": {
  39. "service": "EcomDataService.searchProductsByQuery",
  40. "endpoint": "/api/ProductQuery",
  41. "method": "POST",
  42. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  43. "headers": {
  44. "Authorization": "Bearer {{vocToken}}"
  45. },
  46. "requestBody": {
  47. "Page": 1,
  48. "Query": "1",
  49. "QueryType": "7",
  50. "Pattern": "${categoryKeyword}"
  51. },
  52. "queryParams": {
  53. "domain": "${domain}"
  54. }
  55. },
  56. "output": "categoryProducts",
  57. "responseExtract": "Array<{ Asin, Title, Price, Rating, RatingsCount, MonthlySales, Brand, BSR }>"
  58. },
  59. {
  60. "step": 2,
  61. "name": "批量获取竞品详细定价信息",
  62. "forEach": "competitorAsins",
  63. "api": {
  64. "service": "EcomDataService.getProductDetail",
  65. "endpoint": "/api/ProductRequest",
  66. "method": "POST",
  67. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  68. "headers": {
  69. "Authorization": "Bearer {{vocToken}}"
  70. },
  71. "requestBody": {
  72. "ASIN": "${asin}",
  73. "Trend": 1,
  74. "QueryTrendStartDt": "",
  75. "QueryTrendEndDt": ""
  76. },
  77. "queryParams": {
  78. "domain": "${domain}"
  79. }
  80. },
  81. "output": "competitorDetails",
  82. "responseExtract": "{ Title, Brand, SalesPrice, ListPrice, CouponInfo, FBAFee, Ratings, RatingsCount, MonthlySales }"
  83. },
  84. {
  85. "step": 3,
  86. "name": "获取竞品历史价格趋势",
  87. "forEach": "competitorAsins",
  88. "api": {
  89. "service": "EcomDataService.getMonitorData",
  90. "endpoint": "/api/MonitorQuery",
  91. "method": "POST",
  92. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  93. "headers": {
  94. "Authorization": "Bearer {{vocToken}}"
  95. },
  96. "requestBody": {
  97. "ASIN": "${asin}"
  98. },
  99. "queryParams": {
  100. "domain": "${domain}"
  101. }
  102. },
  103. "output": "priceHistory",
  104. "responseExtract": "{ PriceHistory, RankHistory }"
  105. },
  106. {
  107. "step": 4,
  108. "name": "5分位价格带分析",
  109. "type": "compute",
  110. "logic": "analyzePriceBands(categoryProducts)",
  111. "algorithm": {
  112. "quintile": "按P20/P40/P60/P80划分为低价带/中低/黄金中价/中高/高价带",
  113. "perBand": "每带统计: skuCount, avgSales, avgRating, avgBsr",
  114. "goldenBandScore": "bandScore = avgSales×0.5 + avgRating×20 + (skuCount>0?10:0),最高分为量利平衡最优带"
  115. },
  116. "output": "priceBands"
  117. },
  118. {
  119. "step": 5,
  120. "name": "竞品定价策略识别+毛利估算",
  121. "type": "compute",
  122. "logic": "analyzeCompetitorPricing(competitorDetails, priceHistory, priceBands, ownPrice)",
  123. "algorithm": {
  124. "pricingStrategy": "渗透定价(低于P20)/跟随定价(黄金带内)/溢价定价(高于P80)",
  125. "marginEstimate": "15%佣金+$5FBA+30%采购成本 → grossMargin%, 盈亏平衡销量",
  126. "ownPosition": "自身价格在哪个价格带的哪个百分位",
  127. "optimalPrice": "goldenBandMin + (goldenBandMax-goldenBandMin)*0.6 * min(1.15, max(0.85, selfRating/bandAvgRating))",
  128. "promotionAdvice": "价格战风险检测,优先多件折扣/满减替代降价"
  129. },
  130. "output": "pricingAnalysis"
  131. }
  132. ],
  133. "response": {
  134. "type": "object",
  135. "properties": {
  136. "priceBands": {
  137. "type": "array",
  138. "description": "5分位价格带分布",
  139. "items": {
  140. "type": "object",
  141. "properties": {
  142. "range": {
  143. "type": "string"
  144. },
  145. "label": {
  146. "type": "string"
  147. },
  148. "productCount": {
  149. "type": "integer"
  150. },
  151. "avgRating": {
  152. "type": "number"
  153. },
  154. "avgSales": {
  155. "type": "integer"
  156. },
  157. "isGolden": {
  158. "type": "boolean"
  159. }
  160. }
  161. }
  162. },
  163. "competitorPricing": {
  164. "type": "array",
  165. "description": "竞品定价详情",
  166. "items": {
  167. "type": "object",
  168. "properties": {
  169. "asin": {
  170. "type": "string"
  171. },
  172. "brand": {
  173. "type": "string"
  174. },
  175. "currentPrice": {
  176. "type": "number"
  177. },
  178. "listPrice": {
  179. "type": "number"
  180. },
  181. "coupon": {
  182. "type": "number"
  183. },
  184. "pricingStrategy": {
  185. "type": "string"
  186. },
  187. "priceHistory": {
  188. "type": "array"
  189. },
  190. "estimatedMargin": {
  191. "type": "number"
  192. }
  193. }
  194. }
  195. },
  196. "ownPricePosition": {
  197. "type": "object",
  198. "properties": {
  199. "band": {
  200. "type": "string"
  201. },
  202. "percentile": {
  203. "type": "number"
  204. },
  205. "competitiveness": {
  206. "type": "string"
  207. }
  208. }
  209. },
  210. "recommendation": {
  211. "type": "object",
  212. "properties": {
  213. "optimalRange": {
  214. "type": "array",
  215. "items": {
  216. "type": "number"
  217. }
  218. },
  219. "goldenBand": {
  220. "type": "string"
  221. },
  222. "strategy": {
  223. "type": "string"
  224. },
  225. "reasons": {
  226. "type": "array",
  227. "items": {
  228. "type": "string"
  229. }
  230. }
  231. }
  232. },
  233. "marginEstimate": {
  234. "type": "object",
  235. "properties": {
  236. "currentMargin": {
  237. "type": "number"
  238. },
  239. "suggestedMargin": {
  240. "type": "number"
  241. },
  242. "breakEvenSales": {
  243. "type": "integer"
  244. }
  245. }
  246. },
  247. "promotionAdvice": {
  248. "type": "array",
  249. "items": {
  250. "type": "string"
  251. }
  252. }
  253. }
  254. },
  255. "timeout": 120000,
  256. "retry": {
  257. "maxAttempts": 2,
  258. "delay": 2000,
  259. "backoffMultiplier": 2
  260. },
  261. "tokenConfig": {
  262. "type": "bearer",
  263. "configFile": "~/.openclaw/voc-credentials.json",
  264. "tokenField": "vocToken",
  265. "resolutionOrder": [
  266. "configFile"
  267. ],
  268. "apigId": "7HwdQZk55B",
  269. "paymentUrlResolution": {
  270. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  271. "steps": [
  272. "1. 从 voc-credentials.json 获取当前 session token",
  273. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  274. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  275. "4. 将该URL展示给用户,引导扫码支付"
  276. ],
  277. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  278. "userResolveHeaders": {
  279. "X-Parse-Application-Id": "ncloudmaster",
  280. "X-Parse-Session-Token": "{vocToken}"
  281. },
  282. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  283. "paymentParams": {
  284. "user": "{resolvedUserId}",
  285. "apigid": "7HwdQZk55B",
  286. "fun_id": "HOkkX72PMF"
  287. },
  288. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  289. },
  290. "onMissing": {
  291. "action": "showPaymentQR",
  292. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  293. "title": "扫码开通 VOC-AI 数据服务",
  294. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  295. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  296. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  297. },
  298. "onBalanceInsufficient": {
  299. "action": "resolveUserThenShowPayment",
  300. "title": "VOC-AI Token 余额不足,请扫码充值",
  301. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  302. }
  303. },
  304. "errorHandling": {
  305. "balanceInsufficient": {
  306. "conditions": [
  307. {
  308. "responseField": "code",
  309. "operator": "in",
  310. "value": [
  311. -2,
  312. -3,
  313. -10,
  314. 402,
  315. 429
  316. ]
  317. },
  318. {
  319. "responseField": "msg",
  320. "operator": "contains",
  321. "value": [
  322. "余额不足",
  323. "insufficient",
  324. "balance",
  325. "quota",
  326. "没有开通",
  327. "权限或余额"
  328. ]
  329. },
  330. {
  331. "responseField": "mess",
  332. "operator": "contains",
  333. "value": [
  334. "余额不足",
  335. "insufficient",
  336. "balance",
  337. "quota",
  338. "没有开通",
  339. "权限或余额"
  340. ]
  341. },
  342. {
  343. "responseField": "message",
  344. "operator": "contains",
  345. "value": [
  346. "余额不足",
  347. "insufficient",
  348. "balance",
  349. "没有开通",
  350. "权限或余额"
  351. ]
  352. }
  353. ],
  354. "matchMode": "any",
  355. "trigger": "tokenConfig.onBalanceInsufficient"
  356. },
  357. "unauthorized": {
  358. "conditions": [
  359. {
  360. "responseField": "code",
  361. "operator": "in",
  362. "value": [
  363. 401,
  364. 403
  365. ]
  366. },
  367. {
  368. "responseField": "msg",
  369. "operator": "contains",
  370. "value": [
  371. "unauthorized",
  372. "token",
  373. "invalid",
  374. "auth"
  375. ]
  376. }
  377. ],
  378. "matchMode": "any",
  379. "trigger": "tokenConfig.onMissing"
  380. }
  381. }
  382. }