发送飞书webhook通知

利用工具调用模块,发送一个飞书webhook通知

该文章展示如何发送一个简单的飞书webhook通知,以此类推,发送其他类型的通知也可以这么操作。

发送飞书webhook通知 - 图1发送飞书webhook通知 - 图2

1. 准备飞书机器人

发送飞书webhook通知 - 图3发送飞书webhook通知 - 图4发送飞书webhook通知 - 图5

2. 导入编排代码

复制下面配置,点击「高级编排」右上角的导入按键,导入该配置,导入后将飞书提供的接口地址复制到「HTTP 模块」。

编排配置

  1. [
  2. {
  3. "nodeId": "userGuide",
  4. "name": "core.module.template.App system setting",
  5. "intro": "core.app.tip.userGuideTip",
  6. "avatar": "/imgs/workflow/userGuide.png",
  7. "flowNodeType": "userGuide",
  8. "position": {
  9. "x": -92.26884681344463,
  10. "y": 710.9354029649536
  11. },
  12. "inputs": [
  13. {
  14. "key": "welcomeText",
  15. "type": "hidden",
  16. "valueType": "string",
  17. "label": "core.app.Welcome Text",
  18. "showTargetInApp": false,
  19. "showTargetInPlugin": false,
  20. "value": "",
  21. "connected": false
  22. },
  23. {
  24. "key": "variables",
  25. "type": "hidden",
  26. "valueType": "any",
  27. "label": "core.module.Variable",
  28. "value": [],
  29. "showTargetInApp": false,
  30. "showTargetInPlugin": false,
  31. "connected": false
  32. },
  33. {
  34. "key": "questionGuide",
  35. "valueType": "boolean",
  36. "type": "switch",
  37. "label": "",
  38. "showTargetInApp": false,
  39. "showTargetInPlugin": false,
  40. "value": false,
  41. "connected": false
  42. },
  43. {
  44. "key": "tts",
  45. "type": "hidden",
  46. "valueType": "any",
  47. "label": "",
  48. "showTargetInApp": false,
  49. "showTargetInPlugin": false,
  50. "value": {
  51. "type": "web"
  52. },
  53. "connected": false
  54. }
  55. ],
  56. "outputs": []
  57. },
  58. {
  59. "nodeId": "userChatInput",
  60. "name": "core.module.template.Chat entrance",
  61. "intro": "当用户发送一个内容后,流程将会从这个模块开始执行。",
  62. "avatar": "/imgs/workflow/userChatInput.svg",
  63. "flowNodeType": "questionInput",
  64. "position": {
  65. "x": 241.60980819261408,
  66. "y": 1330.9528898009685
  67. },
  68. "inputs": [
  69. {
  70. "key": "userChatInput",
  71. "type": "systemInput",
  72. "valueType": "string",
  73. "label": "core.module.input.label.user question",
  74. "showTargetInApp": false,
  75. "showTargetInPlugin": false,
  76. "connected": false
  77. }
  78. ],
  79. "outputs": [
  80. {
  81. "key": "userChatInput",
  82. "label": "core.module.input.label.user question",
  83. "type": "source",
  84. "valueType": "string",
  85. "targets": [
  86. {
  87. "nodeId": "n84rvg",
  88. "key": "userChatInput"
  89. }
  90. ]
  91. }
  92. ]
  93. },
  94. {
  95. "nodeId": "n84rvg",
  96. "name": "工具调用(实验)",
  97. "intro": "通过AI模型自动选择一个或多个功能块进行调用,也可以对插件进行调用。",
  98. "avatar": "/imgs/workflow/tool.svg",
  99. "flowNodeType": "tools",
  100. "showStatus": true,
  101. "position": {
  102. "x": 809.4264785615641,
  103. "y": 873.3971746859133
  104. },
  105. "inputs": [
  106. {
  107. "key": "model",
  108. "type": "settingLLMModel",
  109. "label": "core.module.input.label.aiModel",
  110. "required": true,
  111. "valueType": "string",
  112. "showTargetInApp": false,
  113. "showTargetInPlugin": false,
  114. "llmModelType": "all",
  115. "value": "gpt-3.5-turbo",
  116. "connected": false
  117. },
  118. {
  119. "key": "temperature",
  120. "type": "hidden",
  121. "label": "",
  122. "value": 0,
  123. "valueType": "number",
  124. "min": 0,
  125. "max": 10,
  126. "step": 1,
  127. "showTargetInApp": false,
  128. "showTargetInPlugin": false,
  129. "connected": false
  130. },
  131. {
  132. "key": "maxToken",
  133. "type": "hidden",
  134. "label": "",
  135. "value": 2000,
  136. "valueType": "number",
  137. "min": 100,
  138. "max": 4000,
  139. "step": 50,
  140. "showTargetInApp": false,
  141. "showTargetInPlugin": false,
  142. "connected": false
  143. },
  144. {
  145. "key": "systemPrompt",
  146. "type": "textarea",
  147. "max": 3000,
  148. "valueType": "string",
  149. "label": "core.ai.Prompt",
  150. "description": "core.app.tip.chatNodeSystemPromptTip",
  151. "placeholder": "core.app.tip.chatNodeSystemPromptTip",
  152. "showTargetInApp": true,
  153. "showTargetInPlugin": true,
  154. "connected": false
  155. },
  156. {
  157. "key": "history",
  158. "type": "numberInput",
  159. "label": "core.module.input.label.chat history",
  160. "required": true,
  161. "min": 0,
  162. "max": 30,
  163. "valueType": "chatHistory",
  164. "value": 6,
  165. "showTargetInApp": true,
  166. "showTargetInPlugin": true,
  167. "connected": false
  168. },
  169. {
  170. "key": "userChatInput",
  171. "type": "custom",
  172. "label": "",
  173. "required": true,
  174. "valueType": "string",
  175. "showTargetInApp": true,
  176. "showTargetInPlugin": true,
  177. "connected": true
  178. }
  179. ],
  180. "outputs": [
  181. {
  182. "key": "userChatInput",
  183. "label": "core.module.input.label.user question",
  184. "type": "hidden",
  185. "valueType": "string",
  186. "targets": []
  187. },
  188. {
  189. "key": "selectedTools",
  190. "valueType": "tools",
  191. "type": "hidden",
  192. "targets": [
  193. {
  194. "nodeId": "3mbu91",
  195. "key": "selectedTools"
  196. }
  197. ]
  198. },
  199. {
  200. "key": "finish",
  201. "label": "",
  202. "description": "",
  203. "valueType": "boolean",
  204. "type": "hidden",
  205. "targets": []
  206. }
  207. ]
  208. },
  209. {
  210. "nodeId": "3mbu91",
  211. "name": "HTTP 请求",
  212. "intro": "调用飞书webhook,发送一个通知",
  213. "avatar": "/imgs/workflow/http.png",
  214. "flowNodeType": "httpRequest468",
  215. "showStatus": true,
  216. "position": {
  217. "x": 1483.6437630977423,
  218. "y": 798.9716928475544
  219. },
  220. "inputs": [
  221. {
  222. "key": "system_httpMethod",
  223. "type": "custom",
  224. "valueType": "string",
  225. "label": "",
  226. "value": "POST",
  227. "required": true,
  228. "showTargetInApp": false,
  229. "showTargetInPlugin": false,
  230. "connected": false
  231. },
  232. {
  233. "key": "system_httpReqUrl",
  234. "type": "hidden",
  235. "valueType": "string",
  236. "label": "",
  237. "description": "core.module.input.description.Http Request Url",
  238. "placeholder": "https://api.ai.com/getInventory",
  239. "required": false,
  240. "showTargetInApp": false,
  241. "showTargetInPlugin": false,
  242. "value": "这里填写你的飞书机器人地址",
  243. "connected": false
  244. },
  245. {
  246. "key": "system_httpHeader",
  247. "type": "custom",
  248. "valueType": "any",
  249. "value": [],
  250. "label": "",
  251. "description": "core.module.input.description.Http Request Header",
  252. "placeholder": "core.module.input.description.Http Request Header",
  253. "required": false,
  254. "showTargetInApp": false,
  255. "showTargetInPlugin": false,
  256. "connected": false
  257. },
  258. {
  259. "key": "system_httpParams",
  260. "type": "hidden",
  261. "valueType": "any",
  262. "value": [],
  263. "label": "",
  264. "required": false,
  265. "showTargetInApp": false,
  266. "showTargetInPlugin": false,
  267. "connected": false
  268. },
  269. {
  270. "key": "system_httpJsonBody",
  271. "type": "hidden",
  272. "valueType": "any",
  273. "value": "{\r\n \"msg_type\": \"text\",\r\n \"content\": {\r\n \"text\": \"{{text}}\"\r\n }\r\n}",
  274. "label": "",
  275. "required": false,
  276. "showTargetInApp": false,
  277. "showTargetInPlugin": false,
  278. "connected": false
  279. },
  280. {
  281. "key": "DYNAMIC_INPUT_KEY",
  282. "type": "target",
  283. "valueType": "any",
  284. "label": "core.workflow.inputType.dynamicTargetInput",
  285. "description": "core.module.input.description.dynamic input",
  286. "required": false,
  287. "showTargetInApp": false,
  288. "showTargetInPlugin": true,
  289. "hideInApp": true,
  290. "connected": false
  291. },
  292. {
  293. "key": "system_addInputParam",
  294. "type": "addInputParam",
  295. "valueType": "any",
  296. "label": "",
  297. "required": false,
  298. "showTargetInApp": false,
  299. "showTargetInPlugin": false,
  300. "editField": {
  301. "key": true,
  302. "description": true,
  303. "dataType": true
  304. },
  305. "defaultEditField": {
  306. "label": "",
  307. "key": "",
  308. "description": "",
  309. "inputType": "target",
  310. "valueType": "string"
  311. },
  312. "connected": false
  313. },
  314. {
  315. "valueType": "string",
  316. "type": "hidden",
  317. "key": "text",
  318. "label": "text",
  319. "toolDescription": "需要发送的通知内容",
  320. "required": true,
  321. "connected": false
  322. }
  323. ],
  324. "outputs": [
  325. {
  326. "key": "httpRawResponse",
  327. "label": "原始响应",
  328. "description": "HTTP请求的原始响应。只能接受字符串或JSON类型响应数据。",
  329. "valueType": "any",
  330. "type": "source",
  331. "targets": [
  332. {
  333. "nodeId": "rzx4mj",
  334. "key": "switch"
  335. },
  336. {
  337. "nodeId": "psdhs1",
  338. "key": "switch"
  339. }
  340. ]
  341. },
  342. {
  343. "key": "system_addOutputParam",
  344. "type": "addOutputParam",
  345. "valueType": "any",
  346. "label": "",
  347. "targets": [],
  348. "editField": {
  349. "key": true,
  350. "description": true,
  351. "dataType": true,
  352. "defaultValue": true
  353. },
  354. "defaultEditField": {
  355. "label": "",
  356. "key": "",
  357. "description": "",
  358. "outputType": "source",
  359. "valueType": "string"
  360. }
  361. },
  362. {
  363. "type": "source",
  364. "valueType": "string",
  365. "key": "prompt",
  366. "label": "prompt",
  367. "description": "",
  368. "required": false,
  369. "edit": true,
  370. "editField": {
  371. "key": true,
  372. "description": true,
  373. "dataType": true,
  374. "defaultValue": true
  375. },
  376. "targets": []
  377. }
  378. ]
  379. },
  380. {
  381. "nodeId": "rzx4mj",
  382. "name": "工具调用终止",
  383. "intro": "该模块需配置工具调用使用。当该模块被执行时,本次工具调用将会强制结束,并且不再调用AI针对工具调用结果回答问题。",
  384. "avatar": "/imgs/workflow/toolStop.svg",
  385. "flowNodeType": "stopTool",
  386. "position": {
  387. "x": 2145.5070710160267,
  388. "y": 1306.3581817783079
  389. },
  390. "inputs": [
  391. {
  392. "key": "switch",
  393. "type": "triggerAndFinish",
  394. "label": "",
  395. "description": "core.module.input.description.Trigger",
  396. "valueType": "any",
  397. "showTargetInApp": true,
  398. "showTargetInPlugin": true,
  399. "connected": true
  400. }
  401. ],
  402. "outputs": []
  403. },
  404. {
  405. "nodeId": "psdhs1",
  406. "name": "指定回复",
  407. "intro": "该模块可以直接回复一段指定的内容。常用于引导、提示。非字符串内容传入时,会转成字符串进行输出。",
  408. "avatar": "/imgs/workflow/reply.png",
  409. "flowNodeType": "answerNode",
  410. "position": {
  411. "x": 2117.0429459850598,
  412. "y": 1658.4125434513746
  413. },
  414. "inputs": [
  415. {
  416. "key": "switch",
  417. "type": "triggerAndFinish",
  418. "label": "",
  419. "description": "core.module.input.description.Trigger",
  420. "valueType": "any",
  421. "showTargetInApp": true,
  422. "showTargetInPlugin": true,
  423. "connected": true
  424. },
  425. {
  426. "key": "text",
  427. "type": "textarea",
  428. "valueType": "any",
  429. "label": "core.module.input.label.Response content",
  430. "description": "core.module.input.description.Response content",
  431. "placeholder": "core.module.input.description.Response content",
  432. "showTargetInApp": true,
  433. "showTargetInPlugin": true,
  434. "value": "笑死发送成功啦",
  435. "connected": false
  436. }
  437. ],
  438. "outputs": [
  439. {
  440. "key": "finish",
  441. "label": "",
  442. "description": "",
  443. "valueType": "boolean",
  444. "type": "hidden",
  445. "targets": []
  446. }
  447. ]
  448. }
  449. ]

3. 流程说明

  1. 为工具调用挂载一个HTTP模块,功能描述写上:调用飞书webhook,发送一个通知。
  2. HTTP模块的输入参数中,填写飞书机器人的地址,填写发送的通知内容。
  3. HTTP模块输出连接上一个工具终止模块,用于强制结束工具调用。不终止的话,会把调用结果返回给模型,模型会继续回答一次问题,浪费 Tokens
  4. HTTP模块输出再连上一个指定回复,直接回复一个发送成功,用于替代AI的回答。