api-config.json 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. {
  2. "name": "review-batch-collection",
  3. "displayName": "评论批量采集",
  4. "description": "对多个ASIN批量采集Amazon评论,支持翻页和星级过滤,输出结构化评论语料库",
  5. "category": "review-analysis",
  6. "version": "1.3.0",
  7. "type": "orchestration",
  8. "parameters": {
  9. "asins": {
  10. "type": "array",
  11. "items": {
  12. "type": "string"
  13. },
  14. "required": true,
  15. "description": "ASIN列表"
  16. },
  17. "maxPagesPerAsin": {
  18. "type": "integer",
  19. "required": false,
  20. "default": 5,
  21. "description": "每个ASIN最大翻页数"
  22. },
  23. "starFilter": {
  24. "type": "array",
  25. "items": {
  26. "type": "integer",
  27. "enum": [
  28. 1,
  29. 2,
  30. 3,
  31. 4,
  32. 5
  33. ]
  34. },
  35. "required": false,
  36. "description": "星级过滤,不传则全部"
  37. },
  38. "onlyVerifiedPurchase": {
  39. "type": "boolean",
  40. "required": false,
  41. "default": false,
  42. "description": "只采集已验证购买"
  43. },
  44. "domain": {
  45. "type": "integer",
  46. "required": false,
  47. "default": 1,
  48. "description": "Amazon站点"
  49. }
  50. },
  51. "pipeline": [
  52. {
  53. "step": 1,
  54. "name": "批量ASIN×多页评论采集",
  55. "forEach": "asins × [1..maxPagesPerAsin] × (starFilter || [null])",
  56. "api": {
  57. "service": "SorftimeApiService.getProductReviews",
  58. "endpoint": "/api/ProductReviewsQuery",
  59. "method": "POST",
  60. "forwardUrl": "https://server.fmode.cn/api/voc-ecom/forward",
  61. "headers": {
  62. "Authorization": "Bearer {{vocToken}}"
  63. },
  64. "requestBody": {
  65. "ASIN": "${asin}",
  66. "Star": "${star || ''}",
  67. "PageIndex": "${pageIndex}",
  68. "OnlyPurchase": "${onlyVerifiedPurchase ? 1 : 0}",
  69. "QueryStartDt": ""
  70. },
  71. "queryParams": {
  72. "domain": "${domain}"
  73. },
  74. "rateLimit": "400ms between requests per ASIN"
  75. },
  76. "output": "rawReviews",
  77. "responseFields": {
  78. "note": "Sorftime返回的评论字段为PascalCase",
  79. "Star": "integer, 1-5",
  80. "Title": "string, 评论标题",
  81. "Content": "string, 评论正文",
  82. "ConsumerName": "string",
  83. "ConsumerURL": "string, 用户主页链接",
  84. "ReviewsDate": "string, 格式'20260204'",
  85. "ReviewedCountry": "string, 如'United States'",
  86. "IsVP": "boolean, 已验证购买",
  87. "Helpful": "integer",
  88. "ReviewsLink": "string, 评论链接",
  89. "Asin": "string",
  90. "AsinProperty": "string, 变体属性",
  91. "Resource": "array, 图片",
  92. "Videos": "array"
  93. },
  94. "pagination": "多页采集时每页请求间隔400ms避免限流,PageIndex从1开始递增直到无更多数据"
  95. },
  96. {
  97. "step": 2,
  98. "name": "去重+清洗",
  99. "type": "compute",
  100. "logic": "deduplicateAndClean(rawReviews)",
  101. "algorithm": {
  102. "deduplicate": "按ReviewsLink去重",
  103. "clean": "过滤Content长度<10的无效短评论",
  104. "normalize": "统一字段名为cabmelCase: Star→star, Content→content, ReviewsDate→reviewDate"
  105. },
  106. "output": "cleanedReviews"
  107. },
  108. {
  109. "step": 3,
  110. "name": "统计汇总",
  111. "type": "compute",
  112. "logic": "computeStats(cleanedReviews)",
  113. "algorithm": {
  114. "perAsin": "{ total, avgRating, positiveRate(4-5★%), negativeRate(1-2★%), neutralRate(3★%) }",
  115. "overall": "{ totalReviews, asinsCollected, avgStarDistribution }",
  116. "starDistribution": "统计各星级评论数: groupBy(star) → {1:n,2:n,3:n,4:n,5:n}"
  117. },
  118. "output": "stats"
  119. },
  120. {
  121. "step": 4,
  122. "name": "竞品VOC对比汇总",
  123. "type": "compute",
  124. "logic": "computeCompetitorVocComparison(cleanedReviews, asins, { ownAsins })",
  125. "algorithm": {
  126. "grouping": "将ASIN分为本店(ownAsins)和竞品两组",
  127. "perGroup": {
  128. "count": "产品数",
  129. "avgRating": "加权平均评分 = sum(rating*ratingsCount)/sum(ratingsCount)",
  130. "totalReviews": "总评论数",
  131. "negativeRate": "差评率 = avg(1★%+2★%) per product",
  132. "topProducts": "按ratingsCount降序取top5产品: { asin, title(40字), rating, ratingsCount, negativeRate }"
  133. },
  134. "starPctFields": "星级百分比字段: oneStartRatings/twoStartRatings/threeStartRatings/fourStartRatings/fiveStartRatings",
  135. "ratingCalc": "rawRating>0用rawRating; 否则starSum>0时(1*one+2*two+3*three+4*four+5*five)/starSum"
  136. },
  137. "output": "vocComparison"
  138. }
  139. ],
  140. "response": {
  141. "type": "object",
  142. "properties": {
  143. "reviews": {
  144. "type": "array",
  145. "description": "清洗后的评论列表",
  146. "items": {
  147. "type": "object",
  148. "properties": {
  149. "asin": {
  150. "type": "string"
  151. },
  152. "star": {
  153. "type": "integer",
  154. "description": "1-5"
  155. },
  156. "title": {
  157. "type": "string"
  158. },
  159. "content": {
  160. "type": "string"
  161. },
  162. "consumerName": {
  163. "type": "string"
  164. },
  165. "reviewDate": {
  166. "type": "string",
  167. "description": "原始ReviewsDate格式20260204"
  168. },
  169. "isVerifiedPurchase": {
  170. "type": "boolean",
  171. "description": "原始IsVP"
  172. },
  173. "helpful": {
  174. "type": "integer"
  175. },
  176. "reviewLink": {
  177. "type": "string",
  178. "description": "原始ReviewsLink"
  179. },
  180. "variant": {
  181. "type": "string",
  182. "description": "原始AsinProperty"
  183. },
  184. "country": {
  185. "type": "string",
  186. "description": "原始ReviewedCountry"
  187. }
  188. }
  189. }
  190. },
  191. "stats": {
  192. "type": "object",
  193. "description": "采集统计概况",
  194. "properties": {
  195. "totalReviews": {
  196. "type": "integer"
  197. },
  198. "asinsCollected": {
  199. "type": "integer"
  200. },
  201. "avgRating": {
  202. "type": "number"
  203. },
  204. "positiveRate": {
  205. "type": "number"
  206. },
  207. "negativeRate": {
  208. "type": "number"
  209. },
  210. "perAsinStats": {
  211. "type": "object"
  212. }
  213. }
  214. },
  215. "vocComparison": {
  216. "type": "object",
  217. "description": "本店vs竞品VOC对比",
  218. "properties": {
  219. "own": {
  220. "type": "object",
  221. "properties": {
  222. "count": {
  223. "type": "integer"
  224. },
  225. "avgRating": {
  226. "type": "number"
  227. },
  228. "totalReviews": {
  229. "type": "integer"
  230. },
  231. "negativeRate": {
  232. "type": "number"
  233. },
  234. "products": {
  235. "type": "array",
  236. "items": {
  237. "type": "object",
  238. "properties": {
  239. "asin": {
  240. "type": "string"
  241. },
  242. "title": {
  243. "type": "string"
  244. },
  245. "rating": {
  246. "type": "number"
  247. },
  248. "ratingsCount": {
  249. "type": "integer"
  250. },
  251. "negativeRate": {
  252. "type": "number"
  253. }
  254. }
  255. }
  256. }
  257. }
  258. },
  259. "competitor": {
  260. "type": "object",
  261. "properties": {
  262. "count": {
  263. "type": "integer"
  264. },
  265. "avgRating": {
  266. "type": "number"
  267. },
  268. "totalReviews": {
  269. "type": "integer"
  270. },
  271. "negativeRate": {
  272. "type": "number"
  273. },
  274. "products": {
  275. "type": "array",
  276. "items": {
  277. "type": "object",
  278. "properties": {
  279. "asin": {
  280. "type": "string"
  281. },
  282. "title": {
  283. "type": "string"
  284. },
  285. "rating": {
  286. "type": "number"
  287. },
  288. "ratingsCount": {
  289. "type": "integer"
  290. },
  291. "negativeRate": {
  292. "type": "number"
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. },
  303. "timeout": 300000,
  304. "retry": {
  305. "maxAttempts": 3,
  306. "delay": 2000,
  307. "backoffMultiplier": 2
  308. },
  309. "tokenConfig": {
  310. "type": "bearer",
  311. "configFile": "~/.openclaw/voc-credentials.json",
  312. "tokenField": "vocToken",
  313. "resolutionOrder": [
  314. "configFile"
  315. ],
  316. "apigId": "7HwdQZk55B",
  317. "paymentUrlResolution": {
  318. "description": "动态构建充值URL:在已存在 session token 时查出用户 objectId,拼接到专属充值页面",
  319. "steps": [
  320. "1. 从 voc-credentials.json 获取当前 session token",
  321. "2. 调用 GET https://server.fmode.cn/parse/users/me (Header: X-Parse-Application-Id: ncloudmaster, X-Parse-Session-Token: {token})获取用户 objectId",
  322. "3. 拼接充值URL: https://app.fmode.cn/dev/apig-pay/?user={objectId}&apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  323. "4. 将该URL展示给用户,引导扫码支付"
  324. ],
  325. "userResolveEndpoint": "https://server.fmode.cn/parse/users/me",
  326. "userResolveHeaders": {
  327. "X-Parse-Application-Id": "ncloudmaster",
  328. "X-Parse-Session-Token": "{vocToken}"
  329. },
  330. "paymentBaseUrl": "https://app.fmode.cn/dev/apig-pay/",
  331. "paymentParams": {
  332. "user": "{resolvedUserId}",
  333. "apigid": "7HwdQZk55B",
  334. "fun_id": "HOkkX72PMF"
  335. },
  336. "balanceCheckEndpoint": "https://server.fmode.cn/api/apig/getApig"
  337. },
  338. "onMissing": {
  339. "action": "showPaymentQR",
  340. "qrCodeUrl": "https://app.fmode.cn/dev/apig-pay/?apigid=7HwdQZk55B&fun_id=HOkkX72PMF",
  341. "title": "扫码开通 VOC-AI 数据服务",
  342. "message": "此 Skill 需要有效的 API Token。请先打开充值页面完成登录和充值;当用户提供 session token 后,请由 OpenClaw 运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json 的 vocToken 字段,再重试当前 Skill。",
  343. "tokenSetupCommandTemplate": "node scripts/tools/set-voc-token.js {sessionToken}",
  344. "tokenSetupInstructions": "当用户完成登录和充值后,如果用户把 session token 发给你,请直接运行 node scripts/tools/set-voc-token.js <session-token> 写入 ~/.openclaw/voc-credentials.json,然后重试当前 Skill。"
  345. },
  346. "onBalanceInsufficient": {
  347. "action": "resolveUserThenShowPayment",
  348. "title": "VOC-AI Token 余额不足,请扫码充值",
  349. "message": "当前 Token 余额不足,我将为你生成专属充值链接,扫码支付后即可继续使用。"
  350. }
  351. },
  352. "errorHandling": {
  353. "balanceInsufficient": {
  354. "conditions": [
  355. {
  356. "responseField": "code",
  357. "operator": "in",
  358. "value": [
  359. -2,
  360. -3,
  361. -10,
  362. 402,
  363. 429
  364. ]
  365. },
  366. {
  367. "responseField": "msg",
  368. "operator": "contains",
  369. "value": [
  370. "余额不足",
  371. "insufficient",
  372. "balance",
  373. "quota",
  374. "没有开通",
  375. "权限或余额"
  376. ]
  377. },
  378. {
  379. "responseField": "mess",
  380. "operator": "contains",
  381. "value": [
  382. "余额不足",
  383. "insufficient",
  384. "balance",
  385. "quota",
  386. "没有开通",
  387. "权限或余额"
  388. ]
  389. },
  390. {
  391. "responseField": "message",
  392. "operator": "contains",
  393. "value": [
  394. "余额不足",
  395. "insufficient",
  396. "balance",
  397. "没有开通",
  398. "权限或余额"
  399. ]
  400. }
  401. ],
  402. "matchMode": "any",
  403. "trigger": "tokenConfig.onBalanceInsufficient"
  404. },
  405. "unauthorized": {
  406. "conditions": [
  407. {
  408. "responseField": "code",
  409. "operator": "in",
  410. "value": [
  411. 401,
  412. 403
  413. ]
  414. },
  415. {
  416. "responseField": "msg",
  417. "operator": "contains",
  418. "value": [
  419. "unauthorized",
  420. "token",
  421. "invalid",
  422. "auth"
  423. ]
  424. }
  425. ],
  426. "matchMode": "any",
  427. "trigger": "tokenConfig.onMissing"
  428. }
  429. }
  430. }