@renatoascencio/n8n-nodes-chatwoot 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/README.md +248 -9
  2. package/dist/credentials/ChatwootPlatformApi.credentials.d.ts +9 -0
  3. package/dist/credentials/ChatwootPlatformApi.credentials.js +49 -0
  4. package/dist/credentials/ChatwootPlatformApi.credentials.js.map +1 -0
  5. package/dist/credentials/ChatwootPublicApi.credentials.d.ts +7 -0
  6. package/dist/credentials/ChatwootPublicApi.credentials.js +31 -0
  7. package/dist/credentials/ChatwootPublicApi.credentials.js.map +1 -0
  8. package/dist/nodes/Chatwoot/Chatwoot.node.d.ts +4 -1
  9. package/dist/nodes/Chatwoot/Chatwoot.node.js +807 -12
  10. package/dist/nodes/Chatwoot/Chatwoot.node.js.map +1 -1
  11. package/dist/nodes/Chatwoot/GenericFunctions.d.ts +14 -0
  12. package/dist/nodes/Chatwoot/GenericFunctions.js +170 -0
  13. package/dist/nodes/Chatwoot/GenericFunctions.js.map +1 -1
  14. package/dist/nodes/Chatwoot/chatwoot.svg +4 -11
  15. package/dist/nodes/Chatwoot/resources/accountAgentBot/create.operation.d.ts +2 -0
  16. package/dist/nodes/Chatwoot/resources/accountAgentBot/create.operation.js +63 -0
  17. package/dist/nodes/Chatwoot/resources/accountAgentBot/create.operation.js.map +1 -0
  18. package/dist/nodes/Chatwoot/resources/accountAgentBot/delete.operation.d.ts +2 -0
  19. package/dist/nodes/Chatwoot/resources/accountAgentBot/delete.operation.js +34 -0
  20. package/dist/nodes/Chatwoot/resources/accountAgentBot/delete.operation.js.map +1 -0
  21. package/dist/nodes/Chatwoot/resources/accountAgentBot/get.operation.d.ts +2 -0
  22. package/dist/nodes/Chatwoot/resources/accountAgentBot/get.operation.js +34 -0
  23. package/dist/nodes/Chatwoot/resources/accountAgentBot/get.operation.js.map +1 -0
  24. package/dist/nodes/Chatwoot/resources/accountAgentBot/getAll.operation.d.ts +2 -0
  25. package/dist/nodes/Chatwoot/resources/accountAgentBot/getAll.operation.js +20 -0
  26. package/dist/nodes/Chatwoot/resources/accountAgentBot/getAll.operation.js.map +1 -0
  27. package/dist/nodes/Chatwoot/resources/accountAgentBot/index.d.ts +3 -0
  28. package/dist/nodes/Chatwoot/resources/accountAgentBot/index.js +60 -0
  29. package/dist/nodes/Chatwoot/resources/accountAgentBot/index.js.map +1 -0
  30. package/dist/nodes/Chatwoot/resources/accountAgentBot/update.operation.d.ts +2 -0
  31. package/dist/nodes/Chatwoot/resources/accountAgentBot/update.operation.js +70 -0
  32. package/dist/nodes/Chatwoot/resources/accountAgentBot/update.operation.js.map +1 -0
  33. package/dist/nodes/Chatwoot/resources/accountUser/create.operation.d.ts +2 -0
  34. package/dist/nodes/Chatwoot/resources/accountUser/create.operation.js +52 -0
  35. package/dist/nodes/Chatwoot/resources/accountUser/create.operation.js.map +1 -0
  36. package/dist/nodes/Chatwoot/resources/accountUser/delete.operation.d.ts +2 -0
  37. package/dist/nodes/Chatwoot/resources/accountUser/delete.operation.js +34 -0
  38. package/dist/nodes/Chatwoot/resources/accountUser/delete.operation.js.map +1 -0
  39. package/dist/nodes/Chatwoot/resources/accountUser/getAll.operation.d.ts +2 -0
  40. package/dist/nodes/Chatwoot/resources/accountUser/getAll.operation.js +20 -0
  41. package/dist/nodes/Chatwoot/resources/accountUser/getAll.operation.js.map +1 -0
  42. package/dist/nodes/Chatwoot/resources/accountUser/index.d.ts +3 -0
  43. package/dist/nodes/Chatwoot/resources/accountUser/index.js +44 -0
  44. package/dist/nodes/Chatwoot/resources/accountUser/index.js.map +1 -0
  45. package/dist/nodes/Chatwoot/resources/agentBot/index.d.ts +3 -0
  46. package/dist/nodes/Chatwoot/resources/agentBot/index.js +143 -0
  47. package/dist/nodes/Chatwoot/resources/agentBot/index.js.map +1 -0
  48. package/dist/nodes/Chatwoot/resources/auditLog/getAll.operation.d.ts +2 -0
  49. package/dist/nodes/Chatwoot/resources/auditLog/getAll.operation.js +76 -0
  50. package/dist/nodes/Chatwoot/resources/auditLog/getAll.operation.js.map +1 -0
  51. package/dist/nodes/Chatwoot/resources/auditLog/index.d.ts +3 -0
  52. package/dist/nodes/Chatwoot/resources/auditLog/index.js +26 -0
  53. package/dist/nodes/Chatwoot/resources/auditLog/index.js.map +1 -0
  54. package/dist/nodes/Chatwoot/resources/automationRule/index.d.ts +3 -0
  55. package/dist/nodes/Chatwoot/resources/automationRule/index.js +205 -0
  56. package/dist/nodes/Chatwoot/resources/automationRule/index.js.map +1 -0
  57. package/dist/nodes/Chatwoot/resources/contact/addLabels.operation.d.ts +2 -0
  58. package/dist/nodes/Chatwoot/resources/contact/addLabels.operation.js +36 -0
  59. package/dist/nodes/Chatwoot/resources/contact/addLabels.operation.js.map +1 -0
  60. package/dist/nodes/Chatwoot/resources/contact/filter.operation.d.ts +2 -0
  61. package/dist/nodes/Chatwoot/resources/contact/filter.operation.js +51 -0
  62. package/dist/nodes/Chatwoot/resources/contact/filter.operation.js.map +1 -0
  63. package/dist/nodes/Chatwoot/resources/contact/index.js +24 -0
  64. package/dist/nodes/Chatwoot/resources/contact/index.js.map +1 -1
  65. package/dist/nodes/Chatwoot/resources/contact/listLabels.operation.d.ts +2 -0
  66. package/dist/nodes/Chatwoot/resources/contact/listLabels.operation.js +20 -0
  67. package/dist/nodes/Chatwoot/resources/contact/listLabels.operation.js.map +1 -0
  68. package/dist/nodes/Chatwoot/resources/conversation/create.operation.d.ts +2 -0
  69. package/dist/nodes/Chatwoot/resources/conversation/create.operation.js +92 -0
  70. package/dist/nodes/Chatwoot/resources/conversation/create.operation.js.map +1 -0
  71. package/dist/nodes/Chatwoot/resources/conversation/filter.operation.d.ts +2 -0
  72. package/dist/nodes/Chatwoot/resources/conversation/filter.operation.js +51 -0
  73. package/dist/nodes/Chatwoot/resources/conversation/filter.operation.js.map +1 -0
  74. package/dist/nodes/Chatwoot/resources/conversation/getMeta.operation.d.ts +2 -0
  75. package/dist/nodes/Chatwoot/resources/conversation/getMeta.operation.js +55 -0
  76. package/dist/nodes/Chatwoot/resources/conversation/getMeta.operation.js.map +1 -0
  77. package/dist/nodes/Chatwoot/resources/conversation/index.js +56 -0
  78. package/dist/nodes/Chatwoot/resources/conversation/index.js.map +1 -1
  79. package/dist/nodes/Chatwoot/resources/conversation/listLabels.operation.d.ts +2 -0
  80. package/dist/nodes/Chatwoot/resources/conversation/listLabels.operation.js +20 -0
  81. package/dist/nodes/Chatwoot/resources/conversation/listLabels.operation.js.map +1 -0
  82. package/dist/nodes/Chatwoot/resources/conversation/togglePriority.operation.d.ts +2 -0
  83. package/dist/nodes/Chatwoot/resources/conversation/togglePriority.operation.js +41 -0
  84. package/dist/nodes/Chatwoot/resources/conversation/togglePriority.operation.js.map +1 -0
  85. package/dist/nodes/Chatwoot/resources/conversation/update.operation.d.ts +2 -0
  86. package/dist/nodes/Chatwoot/resources/conversation/update.operation.js +56 -0
  87. package/dist/nodes/Chatwoot/resources/conversation/update.operation.js.map +1 -0
  88. package/dist/nodes/Chatwoot/resources/conversation/updateCustomAttributes.operation.d.ts +2 -0
  89. package/dist/nodes/Chatwoot/resources/conversation/updateCustomAttributes.operation.js +34 -0
  90. package/dist/nodes/Chatwoot/resources/conversation/updateCustomAttributes.operation.js.map +1 -0
  91. package/dist/nodes/Chatwoot/resources/csatSurvey/get.operation.d.ts +2 -0
  92. package/dist/nodes/Chatwoot/resources/csatSurvey/get.operation.js +20 -0
  93. package/dist/nodes/Chatwoot/resources/csatSurvey/get.operation.js.map +1 -0
  94. package/dist/nodes/Chatwoot/resources/csatSurvey/index.d.ts +3 -0
  95. package/dist/nodes/Chatwoot/resources/csatSurvey/index.js +26 -0
  96. package/dist/nodes/Chatwoot/resources/csatSurvey/index.js.map +1 -0
  97. package/dist/nodes/Chatwoot/resources/customFilter/index.d.ts +3 -0
  98. package/dist/nodes/Chatwoot/resources/customFilter/index.js +139 -0
  99. package/dist/nodes/Chatwoot/resources/customFilter/index.js.map +1 -0
  100. package/dist/nodes/Chatwoot/resources/helpCenter/createArticle.operation.d.ts +2 -0
  101. package/dist/nodes/Chatwoot/resources/helpCenter/createArticle.operation.js +113 -0
  102. package/dist/nodes/Chatwoot/resources/helpCenter/createArticle.operation.js.map +1 -0
  103. package/dist/nodes/Chatwoot/resources/helpCenter/createCategory.operation.d.ts +2 -0
  104. package/dist/nodes/Chatwoot/resources/helpCenter/createCategory.operation.js +91 -0
  105. package/dist/nodes/Chatwoot/resources/helpCenter/createCategory.operation.js.map +1 -0
  106. package/dist/nodes/Chatwoot/resources/helpCenter/createPortal.operation.d.ts +2 -0
  107. package/dist/nodes/Chatwoot/resources/helpCenter/createPortal.operation.js +84 -0
  108. package/dist/nodes/Chatwoot/resources/helpCenter/createPortal.operation.js.map +1 -0
  109. package/dist/nodes/Chatwoot/resources/helpCenter/getPortal.operation.d.ts +2 -0
  110. package/dist/nodes/Chatwoot/resources/helpCenter/getPortal.operation.js +20 -0
  111. package/dist/nodes/Chatwoot/resources/helpCenter/getPortal.operation.js.map +1 -0
  112. package/dist/nodes/Chatwoot/resources/helpCenter/index.d.ts +3 -0
  113. package/dist/nodes/Chatwoot/resources/helpCenter/index.js +60 -0
  114. package/dist/nodes/Chatwoot/resources/helpCenter/index.js.map +1 -0
  115. package/dist/nodes/Chatwoot/resources/helpCenter/updatePortal.operation.d.ts +2 -0
  116. package/dist/nodes/Chatwoot/resources/helpCenter/updatePortal.operation.js +77 -0
  117. package/dist/nodes/Chatwoot/resources/helpCenter/updatePortal.operation.js.map +1 -0
  118. package/dist/nodes/Chatwoot/resources/inbox/addAgent.operation.d.ts +2 -0
  119. package/dist/nodes/Chatwoot/resources/inbox/addAgent.operation.js +34 -0
  120. package/dist/nodes/Chatwoot/resources/inbox/addAgent.operation.js.map +1 -0
  121. package/dist/nodes/Chatwoot/resources/inbox/create.operation.d.ts +2 -0
  122. package/dist/nodes/Chatwoot/resources/inbox/create.operation.js +110 -0
  123. package/dist/nodes/Chatwoot/resources/inbox/create.operation.js.map +1 -0
  124. package/dist/nodes/Chatwoot/resources/inbox/deleteAgent.operation.d.ts +2 -0
  125. package/dist/nodes/Chatwoot/resources/inbox/deleteAgent.operation.js +34 -0
  126. package/dist/nodes/Chatwoot/resources/inbox/deleteAgent.operation.js.map +1 -0
  127. package/dist/nodes/Chatwoot/resources/inbox/getAgentBot.operation.d.ts +2 -0
  128. package/dist/nodes/Chatwoot/resources/inbox/getAgentBot.operation.js +20 -0
  129. package/dist/nodes/Chatwoot/resources/inbox/getAgentBot.operation.js.map +1 -0
  130. package/dist/nodes/Chatwoot/resources/inbox/getMembers.operation.d.ts +2 -0
  131. package/dist/nodes/Chatwoot/resources/inbox/getMembers.operation.js +20 -0
  132. package/dist/nodes/Chatwoot/resources/inbox/getMembers.operation.js.map +1 -0
  133. package/dist/nodes/Chatwoot/resources/inbox/index.js +48 -0
  134. package/dist/nodes/Chatwoot/resources/inbox/index.js.map +1 -1
  135. package/dist/nodes/Chatwoot/resources/inbox/setAgentBot.operation.d.ts +2 -0
  136. package/dist/nodes/Chatwoot/resources/inbox/setAgentBot.operation.js +36 -0
  137. package/dist/nodes/Chatwoot/resources/inbox/setAgentBot.operation.js.map +1 -0
  138. package/dist/nodes/Chatwoot/resources/integration/createHook.operation.d.ts +2 -0
  139. package/dist/nodes/Chatwoot/resources/integration/createHook.operation.js +47 -0
  140. package/dist/nodes/Chatwoot/resources/integration/createHook.operation.js.map +1 -0
  141. package/dist/nodes/Chatwoot/resources/integration/deleteHook.operation.d.ts +2 -0
  142. package/dist/nodes/Chatwoot/resources/integration/deleteHook.operation.js +34 -0
  143. package/dist/nodes/Chatwoot/resources/integration/deleteHook.operation.js.map +1 -0
  144. package/dist/nodes/Chatwoot/resources/integration/getAll.operation.d.ts +2 -0
  145. package/dist/nodes/Chatwoot/resources/integration/getAll.operation.js +5 -0
  146. package/dist/nodes/Chatwoot/resources/integration/getAll.operation.js.map +1 -0
  147. package/dist/nodes/Chatwoot/resources/integration/index.d.ts +3 -0
  148. package/dist/nodes/Chatwoot/resources/integration/index.js +52 -0
  149. package/dist/nodes/Chatwoot/resources/integration/index.js.map +1 -0
  150. package/dist/nodes/Chatwoot/resources/integration/updateHook.operation.d.ts +2 -0
  151. package/dist/nodes/Chatwoot/resources/integration/updateHook.operation.js +47 -0
  152. package/dist/nodes/Chatwoot/resources/integration/updateHook.operation.js.map +1 -0
  153. package/dist/nodes/Chatwoot/resources/message/delete.operation.d.ts +2 -0
  154. package/dist/nodes/Chatwoot/resources/message/delete.operation.js +34 -0
  155. package/dist/nodes/Chatwoot/resources/message/delete.operation.js.map +1 -0
  156. package/dist/nodes/Chatwoot/resources/message/index.js +20 -1
  157. package/dist/nodes/Chatwoot/resources/message/index.js.map +1 -1
  158. package/dist/nodes/Chatwoot/resources/message/update.operation.d.ts +2 -0
  159. package/dist/nodes/Chatwoot/resources/message/update.operation.js +51 -0
  160. package/dist/nodes/Chatwoot/resources/message/update.operation.js.map +1 -0
  161. package/dist/nodes/Chatwoot/resources/platformAccount/create.operation.d.ts +2 -0
  162. package/dist/nodes/Chatwoot/resources/platformAccount/create.operation.js +56 -0
  163. package/dist/nodes/Chatwoot/resources/platformAccount/create.operation.js.map +1 -0
  164. package/dist/nodes/Chatwoot/resources/platformAccount/delete.operation.d.ts +2 -0
  165. package/dist/nodes/Chatwoot/resources/platformAccount/delete.operation.js +20 -0
  166. package/dist/nodes/Chatwoot/resources/platformAccount/delete.operation.js.map +1 -0
  167. package/dist/nodes/Chatwoot/resources/platformAccount/get.operation.d.ts +2 -0
  168. package/dist/nodes/Chatwoot/resources/platformAccount/get.operation.js +20 -0
  169. package/dist/nodes/Chatwoot/resources/platformAccount/get.operation.js.map +1 -0
  170. package/dist/nodes/Chatwoot/resources/platformAccount/index.d.ts +3 -0
  171. package/dist/nodes/Chatwoot/resources/platformAccount/index.js +52 -0
  172. package/dist/nodes/Chatwoot/resources/platformAccount/index.js.map +1 -0
  173. package/dist/nodes/Chatwoot/resources/platformAccount/update.operation.d.ts +2 -0
  174. package/dist/nodes/Chatwoot/resources/platformAccount/update.operation.js +63 -0
  175. package/dist/nodes/Chatwoot/resources/platformAccount/update.operation.js.map +1 -0
  176. package/dist/nodes/Chatwoot/resources/platformUser/create.operation.d.ts +2 -0
  177. package/dist/nodes/Chatwoot/resources/platformUser/create.operation.js +67 -0
  178. package/dist/nodes/Chatwoot/resources/platformUser/create.operation.js.map +1 -0
  179. package/dist/nodes/Chatwoot/resources/platformUser/delete.operation.d.ts +2 -0
  180. package/dist/nodes/Chatwoot/resources/platformUser/delete.operation.js +20 -0
  181. package/dist/nodes/Chatwoot/resources/platformUser/delete.operation.js.map +1 -0
  182. package/dist/nodes/Chatwoot/resources/platformUser/get.operation.d.ts +2 -0
  183. package/dist/nodes/Chatwoot/resources/platformUser/get.operation.js +20 -0
  184. package/dist/nodes/Chatwoot/resources/platformUser/get.operation.js.map +1 -0
  185. package/dist/nodes/Chatwoot/resources/platformUser/getSsoUrl.operation.d.ts +2 -0
  186. package/dist/nodes/Chatwoot/resources/platformUser/getSsoUrl.operation.js +20 -0
  187. package/dist/nodes/Chatwoot/resources/platformUser/getSsoUrl.operation.js.map +1 -0
  188. package/dist/nodes/Chatwoot/resources/platformUser/index.d.ts +3 -0
  189. package/dist/nodes/Chatwoot/resources/platformUser/index.js +60 -0
  190. package/dist/nodes/Chatwoot/resources/platformUser/index.js.map +1 -0
  191. package/dist/nodes/Chatwoot/resources/platformUser/update.operation.d.ts +2 -0
  192. package/dist/nodes/Chatwoot/resources/platformUser/update.operation.js +66 -0
  193. package/dist/nodes/Chatwoot/resources/platformUser/update.operation.js.map +1 -0
  194. package/dist/nodes/Chatwoot/resources/profile/fetch.operation.d.ts +2 -0
  195. package/dist/nodes/Chatwoot/resources/profile/fetch.operation.js +5 -0
  196. package/dist/nodes/Chatwoot/resources/profile/fetch.operation.js.map +1 -0
  197. package/dist/nodes/Chatwoot/resources/profile/index.d.ts +3 -0
  198. package/dist/nodes/Chatwoot/resources/profile/index.js +26 -0
  199. package/dist/nodes/Chatwoot/resources/profile/index.js.map +1 -0
  200. package/dist/nodes/Chatwoot/resources/publicContact/create.operation.d.ts +2 -0
  201. package/dist/nodes/Chatwoot/resources/publicContact/create.operation.js +63 -0
  202. package/dist/nodes/Chatwoot/resources/publicContact/create.operation.js.map +1 -0
  203. package/dist/nodes/Chatwoot/resources/publicContact/get.operation.d.ts +2 -0
  204. package/dist/nodes/Chatwoot/resources/publicContact/get.operation.js +20 -0
  205. package/dist/nodes/Chatwoot/resources/publicContact/get.operation.js.map +1 -0
  206. package/dist/nodes/Chatwoot/resources/publicContact/index.d.ts +3 -0
  207. package/dist/nodes/Chatwoot/resources/publicContact/index.js +44 -0
  208. package/dist/nodes/Chatwoot/resources/publicContact/index.js.map +1 -0
  209. package/dist/nodes/Chatwoot/resources/publicContact/update.operation.d.ts +2 -0
  210. package/dist/nodes/Chatwoot/resources/publicContact/update.operation.js +70 -0
  211. package/dist/nodes/Chatwoot/resources/publicContact/update.operation.js.map +1 -0
  212. package/dist/nodes/Chatwoot/resources/publicConversation/create.operation.d.ts +2 -0
  213. package/dist/nodes/Chatwoot/resources/publicConversation/create.operation.js +42 -0
  214. package/dist/nodes/Chatwoot/resources/publicConversation/create.operation.js.map +1 -0
  215. package/dist/nodes/Chatwoot/resources/publicConversation/get.operation.d.ts +2 -0
  216. package/dist/nodes/Chatwoot/resources/publicConversation/get.operation.js +34 -0
  217. package/dist/nodes/Chatwoot/resources/publicConversation/get.operation.js.map +1 -0
  218. package/dist/nodes/Chatwoot/resources/publicConversation/getAll.operation.d.ts +2 -0
  219. package/dist/nodes/Chatwoot/resources/publicConversation/getAll.operation.js +20 -0
  220. package/dist/nodes/Chatwoot/resources/publicConversation/getAll.operation.js.map +1 -0
  221. package/dist/nodes/Chatwoot/resources/publicConversation/index.d.ts +3 -0
  222. package/dist/nodes/Chatwoot/resources/publicConversation/index.js +68 -0
  223. package/dist/nodes/Chatwoot/resources/publicConversation/index.js.map +1 -0
  224. package/dist/nodes/Chatwoot/resources/publicConversation/resolve.operation.d.ts +2 -0
  225. package/dist/nodes/Chatwoot/resources/publicConversation/resolve.operation.js +34 -0
  226. package/dist/nodes/Chatwoot/resources/publicConversation/resolve.operation.js.map +1 -0
  227. package/dist/nodes/Chatwoot/resources/publicConversation/toggleTyping.operation.d.ts +2 -0
  228. package/dist/nodes/Chatwoot/resources/publicConversation/toggleTyping.operation.js +52 -0
  229. package/dist/nodes/Chatwoot/resources/publicConversation/toggleTyping.operation.js.map +1 -0
  230. package/dist/nodes/Chatwoot/resources/publicConversation/updateLastSeen.operation.d.ts +2 -0
  231. package/dist/nodes/Chatwoot/resources/publicConversation/updateLastSeen.operation.js +34 -0
  232. package/dist/nodes/Chatwoot/resources/publicConversation/updateLastSeen.operation.js.map +1 -0
  233. package/dist/nodes/Chatwoot/resources/publicMessage/create.operation.d.ts +2 -0
  234. package/dist/nodes/Chatwoot/resources/publicMessage/create.operation.js +73 -0
  235. package/dist/nodes/Chatwoot/resources/publicMessage/create.operation.js.map +1 -0
  236. package/dist/nodes/Chatwoot/resources/publicMessage/getAll.operation.d.ts +2 -0
  237. package/dist/nodes/Chatwoot/resources/publicMessage/getAll.operation.js +34 -0
  238. package/dist/nodes/Chatwoot/resources/publicMessage/getAll.operation.js.map +1 -0
  239. package/dist/nodes/Chatwoot/resources/publicMessage/index.d.ts +3 -0
  240. package/dist/nodes/Chatwoot/resources/publicMessage/index.js +44 -0
  241. package/dist/nodes/Chatwoot/resources/publicMessage/index.js.map +1 -0
  242. package/dist/nodes/Chatwoot/resources/publicMessage/update.operation.d.ts +2 -0
  243. package/dist/nodes/Chatwoot/resources/publicMessage/update.operation.js +65 -0
  244. package/dist/nodes/Chatwoot/resources/publicMessage/update.operation.js.map +1 -0
  245. package/dist/nodes/Chatwoot/resources/report/index.d.ts +3 -0
  246. package/dist/nodes/Chatwoot/resources/report/index.js +155 -0
  247. package/dist/nodes/Chatwoot/resources/report/index.js.map +1 -0
  248. package/dist/nodes/Chatwoot/resources/team/addAgent.operation.d.ts +2 -0
  249. package/dist/nodes/Chatwoot/resources/team/addAgent.operation.js +34 -0
  250. package/dist/nodes/Chatwoot/resources/team/addAgent.operation.js.map +1 -0
  251. package/dist/nodes/Chatwoot/resources/team/deleteAgent.operation.d.ts +2 -0
  252. package/dist/nodes/Chatwoot/resources/team/deleteAgent.operation.js +34 -0
  253. package/dist/nodes/Chatwoot/resources/team/deleteAgent.operation.js.map +1 -0
  254. package/dist/nodes/Chatwoot/resources/team/getMembers.operation.d.ts +2 -0
  255. package/dist/nodes/Chatwoot/resources/team/getMembers.operation.js +20 -0
  256. package/dist/nodes/Chatwoot/resources/team/getMembers.operation.js.map +1 -0
  257. package/dist/nodes/Chatwoot/resources/team/index.js +32 -0
  258. package/dist/nodes/Chatwoot/resources/team/index.js.map +1 -1
  259. package/dist/nodes/Chatwoot/resources/team/updateAgents.operation.d.ts +2 -0
  260. package/dist/nodes/Chatwoot/resources/team/updateAgents.operation.js +34 -0
  261. package/dist/nodes/Chatwoot/resources/team/updateAgents.operation.js.map +1 -0
  262. package/dist/nodes/Chatwoot/types.d.ts +19 -0
  263. package/dist/tsconfig.tsbuildinfo +1 -1
  264. package/package.json +4 -2
@@ -5,15 +5,31 @@ const n8n_workflow_1 = require("n8n-workflow");
5
5
  const GenericFunctions_1 = require("./GenericFunctions");
6
6
  const account_1 = require("./resources/account");
7
7
  const agent_1 = require("./resources/agent");
8
+ const agentBot_1 = require("./resources/agentBot");
9
+ const automationRule_1 = require("./resources/automationRule");
8
10
  const team_1 = require("./resources/team");
9
11
  const inbox_1 = require("./resources/inbox");
10
12
  const label_1 = require("./resources/label");
11
13
  const cannedResponse_1 = require("./resources/cannedResponse");
12
14
  const customAttribute_1 = require("./resources/customAttribute");
15
+ const customFilter_1 = require("./resources/customFilter");
13
16
  const webhook_1 = require("./resources/webhook");
14
17
  const conversation_1 = require("./resources/conversation");
15
18
  const message_1 = require("./resources/message");
16
19
  const contact_1 = require("./resources/contact");
20
+ const report_1 = require("./resources/report");
21
+ const profile_1 = require("./resources/profile");
22
+ const helpCenter_1 = require("./resources/helpCenter");
23
+ const integration_1 = require("./resources/integration");
24
+ const auditLog_1 = require("./resources/auditLog");
25
+ const csatSurvey_1 = require("./resources/csatSurvey");
26
+ const platformAccount_1 = require("./resources/platformAccount");
27
+ const platformUser_1 = require("./resources/platformUser");
28
+ const accountUser_1 = require("./resources/accountUser");
29
+ const accountAgentBot_1 = require("./resources/accountAgentBot");
30
+ const publicContact_1 = require("./resources/publicContact");
31
+ const publicConversation_1 = require("./resources/publicConversation");
32
+ const publicMessage_1 = require("./resources/publicMessage");
17
33
  class Chatwoot {
18
34
  constructor() {
19
35
  this.description = {
@@ -33,6 +49,50 @@ class Chatwoot {
33
49
  {
34
50
  name: 'chatwootApi',
35
51
  required: true,
52
+ displayOptions: {
53
+ show: {
54
+ resource: [
55
+ 'account',
56
+ 'agent',
57
+ 'agentBot',
58
+ 'automationRule',
59
+ 'cannedResponse',
60
+ 'contact',
61
+ 'conversation',
62
+ 'customAttribute',
63
+ 'customFilter',
64
+ 'inbox',
65
+ 'label',
66
+ 'message',
67
+ 'report',
68
+ 'team',
69
+ 'webhook',
70
+ 'profile',
71
+ 'helpCenter',
72
+ 'integration',
73
+ 'auditLog',
74
+ 'csatSurvey',
75
+ ],
76
+ },
77
+ },
78
+ },
79
+ {
80
+ name: 'chatwootPlatformApi',
81
+ required: true,
82
+ displayOptions: {
83
+ show: {
84
+ resource: ['platformAccount', 'platformUser', 'accountUser', 'accountAgentBot'],
85
+ },
86
+ },
87
+ },
88
+ {
89
+ name: 'chatwootPublicApi',
90
+ required: true,
91
+ displayOptions: {
92
+ show: {
93
+ resource: ['publicContact', 'publicConversation', 'publicMessage'],
94
+ },
95
+ },
36
96
  },
37
97
  ],
38
98
  properties: [
@@ -44,40 +104,88 @@ class Chatwoot {
44
104
  options: [
45
105
  { name: 'Account', value: 'account' },
46
106
  { name: 'Agent', value: 'agent' },
107
+ { name: 'Agent Bot', value: 'agentBot' },
108
+ { name: 'Audit Log', value: 'auditLog' },
109
+ { name: 'Automation Rule', value: 'automationRule' },
47
110
  { name: 'Canned Response', value: 'cannedResponse' },
48
111
  { name: 'Contact', value: 'contact' },
49
112
  { name: 'Conversation', value: 'conversation' },
113
+ { name: 'CSAT Survey', value: 'csatSurvey' },
50
114
  { name: 'Custom Attribute', value: 'customAttribute' },
115
+ { name: 'Custom Filter', value: 'customFilter' },
116
+ { name: 'Help Center', value: 'helpCenter' },
51
117
  { name: 'Inbox', value: 'inbox' },
118
+ { name: 'Integration', value: 'integration' },
52
119
  { name: 'Label', value: 'label' },
53
120
  { name: 'Message', value: 'message' },
121
+ { name: 'Profile', value: 'profile' },
122
+ { name: 'Report', value: 'report' },
54
123
  { name: 'Team', value: 'team' },
55
124
  { name: 'Webhook', value: 'webhook' },
125
+ { name: '[Platform] Account', value: 'platformAccount' },
126
+ { name: '[Platform] Account Agent Bot', value: 'accountAgentBot' },
127
+ { name: '[Platform] Account User', value: 'accountUser' },
128
+ { name: '[Platform] User', value: 'platformUser' },
129
+ { name: '[Public] Contact', value: 'publicContact' },
130
+ { name: '[Public] Conversation', value: 'publicConversation' },
131
+ { name: '[Public] Message', value: 'publicMessage' },
56
132
  ],
57
133
  default: 'conversation',
58
134
  },
59
135
  account_1.accountOperations,
60
136
  agent_1.agentOperations,
137
+ agentBot_1.agentBotOperations,
138
+ automationRule_1.automationRuleOperations,
61
139
  team_1.teamOperations,
62
140
  inbox_1.inboxOperations,
63
141
  label_1.labelOperations,
64
142
  cannedResponse_1.cannedResponseOperations,
65
143
  customAttribute_1.customAttributeOperations,
144
+ customFilter_1.customFilterOperations,
66
145
  webhook_1.webhookOperations,
67
146
  conversation_1.conversationOperations,
68
147
  message_1.messageOperations,
69
148
  contact_1.contactOperations,
149
+ report_1.reportOperations,
150
+ profile_1.profileOperations,
151
+ helpCenter_1.helpCenterOperations,
152
+ integration_1.integrationOperations,
153
+ auditLog_1.auditLogOperations,
154
+ csatSurvey_1.csatSurveyOperations,
155
+ platformAccount_1.platformAccountOperations,
156
+ platformUser_1.platformUserOperations,
157
+ accountUser_1.accountUserOperations,
158
+ accountAgentBot_1.accountAgentBotOperations,
159
+ publicContact_1.publicContactOperations,
160
+ publicConversation_1.publicConversationOperations,
161
+ publicMessage_1.publicMessageOperations,
70
162
  ...account_1.accountFields,
71
163
  ...agent_1.agentFields,
164
+ ...agentBot_1.agentBotFields,
165
+ ...automationRule_1.automationRuleFields,
72
166
  ...team_1.teamFields,
73
167
  ...inbox_1.inboxFields,
74
168
  ...label_1.labelFields,
75
169
  ...cannedResponse_1.cannedResponseFields,
76
170
  ...customAttribute_1.customAttributeFields,
171
+ ...customFilter_1.customFilterFields,
77
172
  ...webhook_1.webhookFields,
78
173
  ...conversation_1.conversationFields,
79
174
  ...message_1.messageFields,
80
175
  ...contact_1.contactFields,
176
+ ...report_1.reportFields,
177
+ ...profile_1.profileFields,
178
+ ...helpCenter_1.helpCenterFields,
179
+ ...integration_1.integrationFields,
180
+ ...auditLog_1.auditLogFields,
181
+ ...csatSurvey_1.csatSurveyFields,
182
+ ...platformAccount_1.platformAccountFields,
183
+ ...platformUser_1.platformUserFields,
184
+ ...accountUser_1.accountUserFields,
185
+ ...accountAgentBot_1.accountAgentBotFields,
186
+ ...publicContact_1.publicContactFields,
187
+ ...publicConversation_1.publicConversationFields,
188
+ ...publicMessage_1.publicMessageFields,
81
189
  ],
82
190
  };
83
191
  this.methods = {
@@ -86,6 +194,9 @@ class Chatwoot {
86
194
  getTeams: GenericFunctions_1.getTeams,
87
195
  getInboxes: GenericFunctions_1.getInboxes,
88
196
  getLabels: GenericFunctions_1.getLabels,
197
+ getAgentBots: GenericFunctions_1.getAgentBots,
198
+ getPortals: GenericFunctions_1.getPortals,
199
+ getIntegrations: GenericFunctions_1.getIntegrations,
89
200
  },
90
201
  };
91
202
  }
@@ -198,6 +309,31 @@ class Chatwoot {
198
309
  await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/teams/${teamId}`);
199
310
  responseData = { success: true, id: teamId };
200
311
  }
312
+ else if (operation === 'addAgent') {
313
+ const teamId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('teamId', i), 'Team ID');
314
+ const userIdsStr = this.getNodeParameter('userIds', i);
315
+ const userIds = userIdsStr.split(',').map((id) => parseInt(id.trim(), 10));
316
+ const body = { user_ids: userIds };
317
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/teams/${teamId}/team_members`, body);
318
+ }
319
+ else if (operation === 'deleteAgent') {
320
+ const teamId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('teamId', i), 'Team ID');
321
+ const userIdsStr = this.getNodeParameter('userIds', i);
322
+ const userIds = userIdsStr.split(',').map((id) => parseInt(id.trim(), 10));
323
+ const body = { user_ids: userIds };
324
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/teams/${teamId}/team_members`, body);
325
+ }
326
+ else if (operation === 'getMembers') {
327
+ const teamId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('teamId', i), 'Team ID');
328
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/teams/${teamId}/team_members`);
329
+ }
330
+ else if (operation === 'updateAgents') {
331
+ const teamId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('teamId', i), 'Team ID');
332
+ const userIdsStr = this.getNodeParameter('userIds', i);
333
+ const userIds = userIdsStr.split(',').map((id) => parseInt(id.trim(), 10));
334
+ const body = { user_ids: userIds };
335
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/teams/${teamId}/team_members`, body);
336
+ }
201
337
  else {
202
338
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
203
339
  }
@@ -211,12 +347,57 @@ class Chatwoot {
211
347
  const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
212
348
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/inboxes/${inboxId}`);
213
349
  }
350
+ else if (operation === 'create') {
351
+ const name = this.getNodeParameter('name', i);
352
+ const channelType = this.getNodeParameter('channelType', i);
353
+ const additionalFields = this.getNodeParameter('additionalFields', i);
354
+ const body = { name };
355
+ const channel = { type: channelType };
356
+ if (channelType === 'web_widget') {
357
+ if (additionalFields.website_url)
358
+ channel.website_url = additionalFields.website_url;
359
+ if (additionalFields.welcome_title)
360
+ channel.welcome_title = additionalFields.welcome_title;
361
+ if (additionalFields.welcome_tagline)
362
+ channel.welcome_tagline = additionalFields.welcome_tagline;
363
+ }
364
+ body.channel = channel;
365
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/inboxes', body);
366
+ }
214
367
  else if (operation === 'update') {
215
368
  const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
216
369
  const updateFields = this.getNodeParameter('updateFields', i);
217
370
  const body = { ...updateFields };
218
371
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/inboxes/${inboxId}`, body);
219
372
  }
373
+ else if (operation === 'addAgent') {
374
+ const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
375
+ const userIdsStr = this.getNodeParameter('userIds', i);
376
+ const userIds = userIdsStr.split(',').map((id) => parseInt(id.trim(), 10));
377
+ const body = { user_ids: userIds };
378
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/inbox_members/${inboxId}`, body);
379
+ }
380
+ else if (operation === 'deleteAgent') {
381
+ const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
382
+ const userIdsStr = this.getNodeParameter('userIds', i);
383
+ const userIds = userIdsStr.split(',').map((id) => parseInt(id.trim(), 10));
384
+ const body = { user_ids: userIds };
385
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/inbox_members/${inboxId}`, body);
386
+ }
387
+ else if (operation === 'getMembers') {
388
+ const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
389
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/inbox_members/${inboxId}`);
390
+ }
391
+ else if (operation === 'getAgentBot') {
392
+ const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
393
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/inboxes/${inboxId}/agent_bot`);
394
+ }
395
+ else if (operation === 'setAgentBot') {
396
+ const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
397
+ const agentBotId = this.getNodeParameter('agentBotId', i);
398
+ const body = { agent_bot: agentBotId || null };
399
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/inboxes/${inboxId}/set_agent_bot`, body);
400
+ }
220
401
  else {
221
402
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
222
403
  }
@@ -311,7 +492,7 @@ class Chatwoot {
311
492
  if (additionalFields.default_value)
312
493
  body.default_value = additionalFields.default_value;
313
494
  if (additionalFields.attribute_values) {
314
- body.attribute_values = additionalFields.attribute_values.split(',').map(v => v.trim());
495
+ body.attribute_values = additionalFields.attribute_values.split(',').map((v) => v.trim());
315
496
  }
316
497
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/custom_attribute_definitions', body);
317
498
  }
@@ -326,7 +507,7 @@ class Chatwoot {
326
507
  if (updateFields.default_value)
327
508
  body.default_value = updateFields.default_value;
328
509
  if (updateFields.attribute_values) {
329
- body.attribute_values = updateFields.attribute_values.split(',').map(v => v.trim());
510
+ body.attribute_values = updateFields.attribute_values.split(',').map((v) => v.trim());
330
511
  }
331
512
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/custom_attribute_definitions/${customAttributeId}`, body);
332
513
  }
@@ -382,7 +563,7 @@ class Chatwoot {
382
563
  if (filters.team_id)
383
564
  qs.team_id = filters.team_id;
384
565
  if (filters.labels)
385
- qs.labels = filters.labels.split(',').map(l => l.trim());
566
+ qs.labels = filters.labels.split(',').map((l) => l.trim());
386
567
  if (filters.q)
387
568
  qs.q = filters.q;
388
569
  if (returnAll) {
@@ -391,7 +572,7 @@ class Chatwoot {
391
572
  else {
392
573
  const limit = this.getNodeParameter('limit', i);
393
574
  qs.page = 1;
394
- const result = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations', {}, qs);
575
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations', {}, qs));
395
576
  const payload = (result.payload || []);
396
577
  responseData = payload.slice(0, limit);
397
578
  }
@@ -429,6 +610,84 @@ class Chatwoot {
429
610
  const body = { labels };
430
611
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/labels`, body);
431
612
  }
613
+ else if (operation === 'create') {
614
+ const sourceId = this.getNodeParameter('sourceId', i);
615
+ const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
616
+ const additionalFields = this.getNodeParameter('additionalFields', i);
617
+ const body = {
618
+ source_id: sourceId,
619
+ inbox_id: inboxId,
620
+ };
621
+ if (additionalFields.contact_id)
622
+ body.contact_id = additionalFields.contact_id;
623
+ if (additionalFields.status)
624
+ body.status = additionalFields.status;
625
+ if (additionalFields.assignee_id)
626
+ body.assignee_id = additionalFields.assignee_id;
627
+ if (additionalFields.team_id)
628
+ body.team_id = additionalFields.team_id;
629
+ if (additionalFields.custom_attributes) {
630
+ body.custom_attributes = JSON.parse(additionalFields.custom_attributes);
631
+ }
632
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/conversations', body);
633
+ }
634
+ else if (operation === 'togglePriority') {
635
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
636
+ const priority = this.getNodeParameter('priority', i);
637
+ const body = { priority };
638
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/toggle_priority`, body);
639
+ }
640
+ else if (operation === 'update') {
641
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
642
+ const updateFields = this.getNodeParameter('updateFields', i);
643
+ const body = {};
644
+ if (updateFields.priority)
645
+ body.priority = updateFields.priority;
646
+ if (updateFields.assignee_id)
647
+ body.assignee_id = updateFields.assignee_id;
648
+ if (updateFields.team_id)
649
+ body.team_id = updateFields.team_id;
650
+ if (updateFields.status)
651
+ body.status = updateFields.status;
652
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PUT', `/conversations/${conversationId}`, body);
653
+ }
654
+ else if (operation === 'filter') {
655
+ const filterPayload = this.getNodeParameter('filterPayload', i);
656
+ const returnAll = this.getNodeParameter('returnAll', i);
657
+ const body = { payload: JSON.parse(filterPayload) };
658
+ if (returnAll) {
659
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'POST', '/conversations/filter', body, {}, 'payload');
660
+ }
661
+ else {
662
+ const limit = this.getNodeParameter('limit', i);
663
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/conversations/filter', body));
664
+ const payload = (result.payload || []);
665
+ responseData = payload.slice(0, limit);
666
+ }
667
+ }
668
+ else if (operation === 'updateCustomAttributes') {
669
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
670
+ const customAttributes = this.getNodeParameter('customAttributes', i);
671
+ const body = {
672
+ custom_attributes: JSON.parse(customAttributes),
673
+ };
674
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/conversations/${conversationId}/custom_attributes`, body);
675
+ }
676
+ else if (operation === 'listLabels') {
677
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
678
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/conversations/${conversationId}/labels`);
679
+ }
680
+ else if (operation === 'getMeta') {
681
+ const filters = this.getNodeParameter('filters', i, {});
682
+ const qs = {};
683
+ if (filters.status)
684
+ qs.status = filters.status;
685
+ if (filters.inbox_id)
686
+ qs.inbox_id = filters.inbox_id;
687
+ if (filters.assignee_type)
688
+ qs.assignee_type = filters.assignee_type;
689
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations/meta', {}, qs);
690
+ }
432
691
  else {
433
692
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
434
693
  }
@@ -458,6 +717,19 @@ class Chatwoot {
458
717
  responseData = await GenericFunctions_1.chatwootApiRequestAllMessages.call(this, conversationId, limit);
459
718
  }
460
719
  }
720
+ else if (operation === 'delete') {
721
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
722
+ const messageId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('messageId', i), 'Message ID');
723
+ await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/conversations/${conversationId}/messages/${messageId}`);
724
+ responseData = { success: true, id: messageId };
725
+ }
726
+ else if (operation === 'update') {
727
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
728
+ const messageId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('messageId', i), 'Message ID');
729
+ const content = this.getNodeParameter('content', i);
730
+ const body = { content };
731
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/conversations/${conversationId}/messages/${messageId}`, body);
732
+ }
461
733
  else {
462
734
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
463
735
  }
@@ -477,9 +749,10 @@ class Chatwoot {
477
749
  if (additionalFields.identifier)
478
750
  body.identifier = additionalFields.identifier;
479
751
  if (additionalFields.custom_attributes) {
480
- body.custom_attributes = typeof additionalFields.custom_attributes === 'string'
481
- ? JSON.parse(additionalFields.custom_attributes)
482
- : additionalFields.custom_attributes;
752
+ body.custom_attributes =
753
+ typeof additionalFields.custom_attributes === 'string'
754
+ ? JSON.parse(additionalFields.custom_attributes)
755
+ : additionalFields.custom_attributes;
483
756
  }
484
757
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/contacts', body);
485
758
  }
@@ -499,7 +772,7 @@ class Chatwoot {
499
772
  else {
500
773
  const limit = this.getNodeParameter('limit', i);
501
774
  qs.page = 1;
502
- const result = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/contacts', {}, qs);
775
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/contacts', {}, qs));
503
776
  const payload = (result.payload || []);
504
777
  responseData = payload.slice(0, limit);
505
778
  }
@@ -521,9 +794,10 @@ class Chatwoot {
521
794
  if (updateFields.blocked !== undefined)
522
795
  body.blocked = updateFields.blocked;
523
796
  if (updateFields.custom_attributes) {
524
- body.custom_attributes = typeof updateFields.custom_attributes === 'string'
525
- ? JSON.parse(updateFields.custom_attributes)
526
- : updateFields.custom_attributes;
797
+ body.custom_attributes =
798
+ typeof updateFields.custom_attributes === 'string'
799
+ ? JSON.parse(updateFields.custom_attributes)
800
+ : updateFields.custom_attributes;
527
801
  }
528
802
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PUT', `/contacts/${contactId}`, body);
529
803
  }
@@ -545,7 +819,7 @@ class Chatwoot {
545
819
  else {
546
820
  const limit = this.getNodeParameter('limit', i);
547
821
  qs.page = 1;
548
- const result = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/contacts/search', {}, qs);
822
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/contacts/search', {}, qs));
549
823
  const payload = (result.payload || []);
550
824
  responseData = payload.slice(0, limit);
551
825
  }
@@ -564,6 +838,527 @@ class Chatwoot {
564
838
  };
565
839
  responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/actions/contact_merge', body);
566
840
  }
841
+ else if (operation === 'filter') {
842
+ const filterPayload = this.getNodeParameter('filterPayload', i);
843
+ const returnAll = this.getNodeParameter('returnAll', i);
844
+ const body = { payload: JSON.parse(filterPayload) };
845
+ if (returnAll) {
846
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'POST', '/contacts/filter', body, {}, 'payload');
847
+ }
848
+ else {
849
+ const limit = this.getNodeParameter('limit', i);
850
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/contacts/filter', body));
851
+ const payload = (result.payload || []);
852
+ responseData = payload.slice(0, limit);
853
+ }
854
+ }
855
+ else if (operation === 'addLabels') {
856
+ const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
857
+ const labels = this.getNodeParameter('labels', i);
858
+ const body = { labels };
859
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/contacts/${contactId}/labels`, body);
860
+ }
861
+ else if (operation === 'listLabels') {
862
+ const contactId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('contactId', i), 'Contact ID');
863
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/contacts/${contactId}/labels`);
864
+ }
865
+ else {
866
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
867
+ }
868
+ }
869
+ else if (resource === 'agentBot') {
870
+ if (operation === 'getAll') {
871
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/agent_bots');
872
+ }
873
+ else if (operation === 'get') {
874
+ const agentBotId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('agentBotId', i), 'Agent Bot ID');
875
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/agent_bots/${agentBotId}`);
876
+ }
877
+ else if (operation === 'create') {
878
+ const name = this.getNodeParameter('name', i);
879
+ const additionalFields = this.getNodeParameter('additionalFields', i);
880
+ const body = { name };
881
+ if (additionalFields.description)
882
+ body.description = additionalFields.description;
883
+ if (additionalFields.outgoing_url)
884
+ body.outgoing_url = additionalFields.outgoing_url;
885
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/agent_bots', body);
886
+ }
887
+ else if (operation === 'update') {
888
+ const agentBotId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('agentBotId', i), 'Agent Bot ID');
889
+ const updateFields = this.getNodeParameter('updateFields', i);
890
+ const body = { ...updateFields };
891
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/agent_bots/${agentBotId}`, body);
892
+ }
893
+ else if (operation === 'delete') {
894
+ const agentBotId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('agentBotId', i), 'Agent Bot ID');
895
+ await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/agent_bots/${agentBotId}`);
896
+ responseData = { success: true, id: agentBotId };
897
+ }
898
+ else {
899
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
900
+ }
901
+ }
902
+ else if (resource === 'automationRule') {
903
+ if (operation === 'getAll') {
904
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/automation_rules');
905
+ }
906
+ else if (operation === 'get') {
907
+ const automationRuleId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('automationRuleId', i), 'Automation Rule ID');
908
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/automation_rules/${automationRuleId}`);
909
+ }
910
+ else if (operation === 'create') {
911
+ const name = this.getNodeParameter('name', i);
912
+ const eventName = this.getNodeParameter('eventName', i);
913
+ const conditions = JSON.parse(this.getNodeParameter('conditions', i));
914
+ const actions = JSON.parse(this.getNodeParameter('actions', i));
915
+ const additionalFields = this.getNodeParameter('additionalFields', i);
916
+ const body = {
917
+ name,
918
+ event_name: eventName,
919
+ conditions,
920
+ actions,
921
+ };
922
+ if (additionalFields.description)
923
+ body.description = additionalFields.description;
924
+ if (additionalFields.active !== undefined)
925
+ body.active = additionalFields.active;
926
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/automation_rules', body);
927
+ }
928
+ else if (operation === 'update') {
929
+ const automationRuleId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('automationRuleId', i), 'Automation Rule ID');
930
+ const updateFields = this.getNodeParameter('updateFields', i);
931
+ const body = {};
932
+ if (updateFields.name)
933
+ body.name = updateFields.name;
934
+ if (updateFields.description)
935
+ body.description = updateFields.description;
936
+ if (updateFields.active !== undefined)
937
+ body.active = updateFields.active;
938
+ if (updateFields.conditions)
939
+ body.conditions = JSON.parse(updateFields.conditions);
940
+ if (updateFields.actions)
941
+ body.actions = JSON.parse(updateFields.actions);
942
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/automation_rules/${automationRuleId}`, body);
943
+ }
944
+ else if (operation === 'delete') {
945
+ const automationRuleId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('automationRuleId', i), 'Automation Rule ID');
946
+ await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/automation_rules/${automationRuleId}`);
947
+ responseData = { success: true, id: automationRuleId };
948
+ }
949
+ else {
950
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
951
+ }
952
+ }
953
+ else if (resource === 'customFilter') {
954
+ if (operation === 'getAll') {
955
+ const filterType = this.getNodeParameter('filterType', i);
956
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/custom_filters', {}, { filter_type: filterType });
957
+ }
958
+ else if (operation === 'get') {
959
+ const customFilterId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('customFilterId', i), 'Custom Filter ID');
960
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/custom_filters/${customFilterId}`);
961
+ }
962
+ else if (operation === 'create') {
963
+ const name = this.getNodeParameter('name', i);
964
+ const filterType = this.getNodeParameter('filterType', i);
965
+ const query = JSON.parse(this.getNodeParameter('query', i));
966
+ const body = {
967
+ name,
968
+ filter_type: filterType,
969
+ query,
970
+ };
971
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/custom_filters', body);
972
+ }
973
+ else if (operation === 'update') {
974
+ const customFilterId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('customFilterId', i), 'Custom Filter ID');
975
+ const updateFields = this.getNodeParameter('updateFields', i);
976
+ const body = {};
977
+ if (updateFields.name)
978
+ body.name = updateFields.name;
979
+ if (updateFields.query)
980
+ body.query = JSON.parse(updateFields.query);
981
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/custom_filters/${customFilterId}`, body);
982
+ }
983
+ else if (operation === 'delete') {
984
+ const customFilterId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('customFilterId', i), 'Custom Filter ID');
985
+ await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/custom_filters/${customFilterId}`);
986
+ responseData = { success: true, id: customFilterId };
987
+ }
988
+ else {
989
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
990
+ }
991
+ }
992
+ else if (resource === 'report') {
993
+ const qs = {};
994
+ if (operation === 'accountSummary') {
995
+ const since = new Date(this.getNodeParameter('since', i)).getTime() / 1000;
996
+ const until = new Date(this.getNodeParameter('until', i)).getTime() / 1000;
997
+ const metric = this.getNodeParameter('metric', i);
998
+ const options = this.getNodeParameter('options', i);
999
+ qs.since = since;
1000
+ qs.until = until;
1001
+ qs.metric = metric;
1002
+ if (options.type)
1003
+ qs.type = options.type;
1004
+ if (options.id)
1005
+ qs.id = options.id;
1006
+ if (options.timezone_offset)
1007
+ qs.timezone_offset = options.timezone_offset;
1008
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/reports/summary', {}, qs);
1009
+ }
1010
+ else if (operation === 'agentStatistics') {
1011
+ const since = new Date(this.getNodeParameter('since', i)).getTime() / 1000;
1012
+ const until = new Date(this.getNodeParameter('until', i)).getTime() / 1000;
1013
+ const options = this.getNodeParameter('options', i);
1014
+ qs.since = since;
1015
+ qs.until = until;
1016
+ if (options.timezone_offset)
1017
+ qs.timezone_offset = options.timezone_offset;
1018
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/reports/agents', {}, qs);
1019
+ }
1020
+ else if (operation === 'conversationCounts') {
1021
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/conversations/meta');
1022
+ }
1023
+ else if (operation === 'conversationStatistics') {
1024
+ const since = new Date(this.getNodeParameter('since', i)).getTime() / 1000;
1025
+ const until = new Date(this.getNodeParameter('until', i)).getTime() / 1000;
1026
+ const groupBy = this.getNodeParameter('groupBy', i);
1027
+ const options = this.getNodeParameter('options', i);
1028
+ qs.since = since;
1029
+ qs.until = until;
1030
+ if (options.timezone_offset)
1031
+ qs.timezone_offset = options.timezone_offset;
1032
+ let endpoint = '/reports';
1033
+ if (groupBy === 'agent')
1034
+ endpoint = '/reports/conversations';
1035
+ else if (groupBy === 'inbox')
1036
+ endpoint = '/reports/inboxes';
1037
+ else if (groupBy === 'team')
1038
+ endpoint = '/reports/teams';
1039
+ else if (groupBy === 'channel_type')
1040
+ endpoint = '/reports/conversations';
1041
+ qs.type = groupBy;
1042
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', endpoint, {}, qs);
1043
+ }
1044
+ else {
1045
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1046
+ }
1047
+ }
1048
+ else if (resource === 'profile') {
1049
+ if (operation === 'fetch') {
1050
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/profile');
1051
+ }
1052
+ else {
1053
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1054
+ }
1055
+ }
1056
+ else if (resource === 'helpCenter') {
1057
+ if (operation === 'createPortal') {
1058
+ const name = this.getNodeParameter('name', i);
1059
+ const slug = this.getNodeParameter('slug', i);
1060
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1061
+ const body = { name, slug, ...additionalFields };
1062
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/portals', body);
1063
+ }
1064
+ else if (operation === 'getPortal') {
1065
+ const portalSlug = this.getNodeParameter('portalSlug', i);
1066
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/portals/${portalSlug}`);
1067
+ }
1068
+ else if (operation === 'updatePortal') {
1069
+ const portalSlug = this.getNodeParameter('portalSlug', i);
1070
+ const updateFields = this.getNodeParameter('updateFields', i);
1071
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/portals/${portalSlug}`, updateFields);
1072
+ }
1073
+ else if (operation === 'createCategory') {
1074
+ const portalSlug = this.getNodeParameter('portalSlug', i);
1075
+ const name = this.getNodeParameter('name', i);
1076
+ const slug = this.getNodeParameter('slug', i);
1077
+ const locale = this.getNodeParameter('locale', i);
1078
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1079
+ const body = { name, slug, locale, ...additionalFields };
1080
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/portals/${portalSlug}/categories`, body);
1081
+ }
1082
+ else if (operation === 'createArticle') {
1083
+ const portalSlug = this.getNodeParameter('portalSlug', i);
1084
+ const title = this.getNodeParameter('title', i);
1085
+ const content = this.getNodeParameter('content', i);
1086
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1087
+ const body = { title, content, ...additionalFields };
1088
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', `/portals/${portalSlug}/articles`, body);
1089
+ }
1090
+ else {
1091
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1092
+ }
1093
+ }
1094
+ else if (resource === 'integration') {
1095
+ if (operation === 'getAll') {
1096
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/integrations/apps');
1097
+ }
1098
+ else if (operation === 'createHook') {
1099
+ const appId = this.getNodeParameter('appId', i);
1100
+ const inboxId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('inboxId', i), 'Inbox ID');
1101
+ const settings = JSON.parse(this.getNodeParameter('settings', i));
1102
+ const body = { app_id: appId, inbox_id: inboxId, settings };
1103
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'POST', '/integrations/hooks', body);
1104
+ }
1105
+ else if (operation === 'updateHook') {
1106
+ const hookId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('hookId', i), 'Hook ID');
1107
+ const settings = JSON.parse(this.getNodeParameter('settings', i));
1108
+ const body = { settings };
1109
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'PATCH', `/integrations/hooks/${hookId}`, body);
1110
+ }
1111
+ else if (operation === 'deleteHook') {
1112
+ const hookId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('hookId', i), 'Hook ID');
1113
+ await GenericFunctions_1.chatwootApiRequest.call(this, 'DELETE', `/integrations/hooks/${hookId}`);
1114
+ responseData = { success: true, id: hookId };
1115
+ }
1116
+ else {
1117
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1118
+ }
1119
+ }
1120
+ else if (resource === 'auditLog') {
1121
+ if (operation === 'getAll') {
1122
+ const returnAll = this.getNodeParameter('returnAll', i);
1123
+ const filters = this.getNodeParameter('filters', i);
1124
+ const qs = {};
1125
+ if (filters.auditable_type)
1126
+ qs.auditable_type = filters.auditable_type;
1127
+ if (filters.user_id)
1128
+ qs.user_id = filters.user_id;
1129
+ if (returnAll) {
1130
+ responseData = await GenericFunctions_1.chatwootApiRequestAllItems.call(this, 'GET', '/audit_logs', {}, qs, 'payload');
1131
+ }
1132
+ else {
1133
+ const limit = this.getNodeParameter('limit', i);
1134
+ qs.page = 1;
1135
+ const result = (await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', '/audit_logs', {}, qs));
1136
+ const payload = (result.payload || []);
1137
+ responseData = payload.slice(0, limit);
1138
+ }
1139
+ }
1140
+ else {
1141
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1142
+ }
1143
+ }
1144
+ else if (resource === 'csatSurvey') {
1145
+ if (operation === 'get') {
1146
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1147
+ responseData = await GenericFunctions_1.chatwootApiRequest.call(this, 'GET', `/csat_survey/${conversationId}`);
1148
+ }
1149
+ else {
1150
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1151
+ }
1152
+ }
1153
+ else if (resource === 'platformAccount') {
1154
+ if (operation === 'create') {
1155
+ const name = this.getNodeParameter('name', i);
1156
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1157
+ const body = { name, ...additionalFields };
1158
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'POST', '/accounts', body);
1159
+ }
1160
+ else if (operation === 'get') {
1161
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1162
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'GET', `/accounts/${accountId}`);
1163
+ }
1164
+ else if (operation === 'update') {
1165
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1166
+ const updateFields = this.getNodeParameter('updateFields', i);
1167
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'PATCH', `/accounts/${accountId}`, updateFields);
1168
+ }
1169
+ else if (operation === 'delete') {
1170
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1171
+ await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'DELETE', `/accounts/${accountId}`);
1172
+ responseData = { success: true, id: accountId };
1173
+ }
1174
+ else {
1175
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1176
+ }
1177
+ }
1178
+ else if (resource === 'platformUser') {
1179
+ if (operation === 'create') {
1180
+ const email = this.getNodeParameter('email', i);
1181
+ const name = this.getNodeParameter('name', i);
1182
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1183
+ const body = { email, name };
1184
+ if (additionalFields.password)
1185
+ body.password = additionalFields.password;
1186
+ if (additionalFields.custom_attributes) {
1187
+ body.custom_attributes = JSON.parse(additionalFields.custom_attributes);
1188
+ }
1189
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'POST', '/users', body);
1190
+ }
1191
+ else if (operation === 'get') {
1192
+ const userId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('userId', i), 'User ID');
1193
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'GET', `/users/${userId}`);
1194
+ }
1195
+ else if (operation === 'update') {
1196
+ const userId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('userId', i), 'User ID');
1197
+ const updateFields = this.getNodeParameter('updateFields', i);
1198
+ if (updateFields.custom_attributes && typeof updateFields.custom_attributes === 'string') {
1199
+ updateFields.custom_attributes = JSON.parse(updateFields.custom_attributes);
1200
+ }
1201
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'PATCH', `/users/${userId}`, updateFields);
1202
+ }
1203
+ else if (operation === 'delete') {
1204
+ const userId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('userId', i), 'User ID');
1205
+ await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'DELETE', `/users/${userId}`);
1206
+ responseData = { success: true, id: userId };
1207
+ }
1208
+ else if (operation === 'getSsoUrl') {
1209
+ const userId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('userId', i), 'User ID');
1210
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'GET', `/users/${userId}/login`);
1211
+ }
1212
+ else {
1213
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1214
+ }
1215
+ }
1216
+ else if (resource === 'accountUser') {
1217
+ if (operation === 'getAll') {
1218
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1219
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'GET', `/accounts/${accountId}/account_users`);
1220
+ }
1221
+ else if (operation === 'create') {
1222
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1223
+ const userId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('userId', i), 'User ID');
1224
+ const role = this.getNodeParameter('role', i);
1225
+ const body = { user_id: userId, role };
1226
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'POST', `/accounts/${accountId}/account_users`, body);
1227
+ }
1228
+ else if (operation === 'delete') {
1229
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1230
+ const userId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('userId', i), 'User ID');
1231
+ await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'DELETE', `/accounts/${accountId}/account_users`, { user_id: userId });
1232
+ responseData = { success: true, accountId, userId };
1233
+ }
1234
+ else {
1235
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1236
+ }
1237
+ }
1238
+ else if (resource === 'accountAgentBot') {
1239
+ if (operation === 'getAll') {
1240
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1241
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'GET', `/accounts/${accountId}/agent_bots`);
1242
+ }
1243
+ else if (operation === 'get') {
1244
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1245
+ const agentBotId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('agentBotId', i), 'Agent Bot ID');
1246
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'GET', `/accounts/${accountId}/agent_bots/${agentBotId}`);
1247
+ }
1248
+ else if (operation === 'create') {
1249
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1250
+ const name = this.getNodeParameter('name', i);
1251
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1252
+ const body = { name, ...additionalFields };
1253
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'POST', `/accounts/${accountId}/agent_bots`, body);
1254
+ }
1255
+ else if (operation === 'update') {
1256
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1257
+ const agentBotId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('agentBotId', i), 'Agent Bot ID');
1258
+ const updateFields = this.getNodeParameter('updateFields', i);
1259
+ responseData = await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'PATCH', `/accounts/${accountId}/agent_bots/${agentBotId}`, updateFields);
1260
+ }
1261
+ else if (operation === 'delete') {
1262
+ const accountId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('accountId', i), 'Account ID');
1263
+ const agentBotId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('agentBotId', i), 'Agent Bot ID');
1264
+ await GenericFunctions_1.chatwootPlatformApiRequest.call(this, 'DELETE', `/accounts/${accountId}/agent_bots/${agentBotId}`);
1265
+ responseData = { success: true, id: agentBotId };
1266
+ }
1267
+ else {
1268
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1269
+ }
1270
+ }
1271
+ else if (resource === 'publicContact') {
1272
+ const credentials = await this.getCredentials('chatwootPublicApi');
1273
+ const inboxIdentifier = credentials.inboxIdentifier;
1274
+ if (operation === 'create') {
1275
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1276
+ if (additionalFields.custom_attributes && typeof additionalFields.custom_attributes === 'string') {
1277
+ additionalFields.custom_attributes = JSON.parse(additionalFields.custom_attributes);
1278
+ }
1279
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'POST', `/inboxes/${inboxIdentifier}/contacts`, additionalFields);
1280
+ }
1281
+ else if (operation === 'get') {
1282
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1283
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'GET', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}`);
1284
+ }
1285
+ else if (operation === 'update') {
1286
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1287
+ const updateFields = this.getNodeParameter('updateFields', i);
1288
+ if (updateFields.custom_attributes && typeof updateFields.custom_attributes === 'string') {
1289
+ updateFields.custom_attributes = JSON.parse(updateFields.custom_attributes);
1290
+ }
1291
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'PATCH', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}`, updateFields);
1292
+ }
1293
+ else {
1294
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1295
+ }
1296
+ }
1297
+ else if (resource === 'publicConversation') {
1298
+ const credentials = await this.getCredentials('chatwootPublicApi');
1299
+ const inboxIdentifier = credentials.inboxIdentifier;
1300
+ if (operation === 'create') {
1301
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1302
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1303
+ if (additionalFields.custom_attributes && typeof additionalFields.custom_attributes === 'string') {
1304
+ additionalFields.custom_attributes = JSON.parse(additionalFields.custom_attributes);
1305
+ }
1306
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'POST', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations`, additionalFields);
1307
+ }
1308
+ else if (operation === 'get') {
1309
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1310
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1311
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'GET', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations/${conversationId}`);
1312
+ }
1313
+ else if (operation === 'getAll') {
1314
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1315
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'GET', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations`);
1316
+ }
1317
+ else if (operation === 'resolve') {
1318
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1319
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1320
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'POST', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations/${conversationId}/toggle_status`);
1321
+ }
1322
+ else if (operation === 'toggleTyping') {
1323
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1324
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1325
+ const typingStatus = this.getNodeParameter('typingStatus', i);
1326
+ const body = { typing_status: typingStatus };
1327
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'POST', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations/${conversationId}/toggle_typing`, body);
1328
+ }
1329
+ else if (operation === 'updateLastSeen') {
1330
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1331
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1332
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'POST', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations/${conversationId}/update_last_seen`);
1333
+ }
1334
+ else {
1335
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
1336
+ }
1337
+ }
1338
+ else if (resource === 'publicMessage') {
1339
+ const credentials = await this.getCredentials('chatwootPublicApi');
1340
+ const inboxIdentifier = credentials.inboxIdentifier;
1341
+ if (operation === 'create') {
1342
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1343
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1344
+ const content = this.getNodeParameter('content', i);
1345
+ const additionalFields = this.getNodeParameter('additionalFields', i);
1346
+ const body = { content, ...additionalFields };
1347
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'POST', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations/${conversationId}/messages`, body);
1348
+ }
1349
+ else if (operation === 'getAll') {
1350
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1351
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1352
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'GET', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations/${conversationId}/messages`);
1353
+ }
1354
+ else if (operation === 'update') {
1355
+ const contactIdentifier = this.getNodeParameter('contactIdentifier', i);
1356
+ const conversationId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('conversationId', i), 'Conversation ID');
1357
+ const messageId = (0, GenericFunctions_1.validateId)(this.getNodeParameter('messageId', i), 'Message ID');
1358
+ const content = this.getNodeParameter('content', i);
1359
+ const body = { content };
1360
+ responseData = await GenericFunctions_1.chatwootPublicApiRequest.call(this, 'PATCH', `/inboxes/${inboxIdentifier}/contacts/${contactIdentifier}/conversations/${conversationId}/messages/${messageId}`, body);
1361
+ }
567
1362
  else {
568
1363
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation "${operation}" not supported`, { itemIndex: i });
569
1364
  }