chatwoot.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /** Realistic Chatwoot webhook payloads used across the test suite. */
  2. export const incomingEmailMessage = {
  3. event: 'message_created',
  4. id: 90210,
  5. message_type: 'incoming',
  6. content_type: 'incoming_email',
  7. content: 'Dzień dobry, czy gaz R1234yf pasuje do mojego Golfa VII z 2016 roku?',
  8. created_at: Math.floor(Date.now() / 1000),
  9. private: false,
  10. conversation: {
  11. id: 1311,
  12. inbox_id: 1,
  13. status: 'open',
  14. channel: 'Channel::Email',
  15. labels: [],
  16. custom_attributes: {},
  17. additional_attributes: {
  18. source: 'email',
  19. mail_subject: 'Pytanie o klimatyzację',
  20. },
  21. meta: {
  22. sender: { id: 332, name: 'Jan Kowalski', email: 'jan.kowalski@example.com' },
  23. },
  24. contact_inbox: { source_id: 'jan.kowalski@example.com' },
  25. },
  26. sender: { id: 332, name: 'Jan Kowalski', email: 'jan.kowalski@example.com' },
  27. attachments: [],
  28. };
  29. export const outgoingMessage = {
  30. ...incomingEmailMessage,
  31. id: 90211,
  32. message_type: 'outgoing',
  33. };
  34. export const privateNote = {
  35. ...incomingEmailMessage,
  36. id: 90212,
  37. private: true,
  38. };
  39. export const statusUpdate = {
  40. event: 'conversation_status_changed',
  41. id: 90213,
  42. conversation: { id: 1311 },
  43. };
  44. export const missingConversationId = {
  45. event: 'message_created',
  46. id: 90214,
  47. message_type: 'incoming',
  48. content: 'hello',
  49. conversation: {},
  50. };
  51. export const ticketedConversationMessage = {
  52. ...incomingEmailMessage,
  53. id: 90215,
  54. conversation: {
  55. ...incomingEmailMessage.conversation,
  56. labels: ['ticket'],
  57. custom_attributes: { ticket_number: 'EKS-20260820-1311', handoff: true },
  58. },
  59. };
  60. export const bounceMessage = {
  61. ...incomingEmailMessage,
  62. id: 90216,
  63. content: 'This is the mail system at host mx.example.com. Your message could not be delivered.',
  64. conversation: {
  65. ...incomingEmailMessage.conversation,
  66. additional_attributes: {
  67. source: 'email',
  68. mail_subject: 'Undelivered Mail Returned to Sender',
  69. },
  70. meta: { sender: { id: 9, name: '', email: 'mailer-daemon@example.com' } },
  71. },
  72. sender: { id: 9, name: '', email: 'mailer-daemon@example.com' },
  73. };
  74. export const noLabelsPayload = {
  75. event: 'message_created',
  76. id: 90217,
  77. message_type: 'incoming',
  78. content: 'Gdzie jest moja paczka?',
  79. created_at: Math.floor(Date.now() / 1000),
  80. conversation: {
  81. id: 1412,
  82. inbox_id: 1,
  83. channel: 'Channel::Email',
  84. },
  85. sender: { id: 401, name: 'Anna Nowak', email: 'anna.nowak@example.com' },
  86. };