triggers.rb 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Trigger.create_or_update(
  2. name: 'auto reply (on new tickets)',
  3. condition: {
  4. 'ticket.action' => {
  5. 'operator' => 'is',
  6. 'value' => 'create',
  7. },
  8. 'ticket.state_id' => {
  9. 'operator' => 'is not',
  10. 'value' => Ticket::State.by_category(:closed).first.id,
  11. },
  12. 'article.type_id' => {
  13. 'operator' => 'is',
  14. 'value' => [
  15. Ticket::Article::Type.lookup(name: 'email').id,
  16. Ticket::Article::Type.lookup(name: 'phone').id,
  17. Ticket::Article::Type.lookup(name: 'web').id,
  18. ],
  19. },
  20. 'article.sender_id' => {
  21. 'operator' => 'is',
  22. 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
  23. },
  24. },
  25. perform: {
  26. 'notification.email' => {
  27. 'body' => '<div>Your request <b>(#{config.ticket_hook}#{ticket.number})</b> has been received and will be reviewed by our support staff.</div>
  28. <br/>
  29. <div>To provide additional information, please reply to this email or click on the following link (for initial login, please request a new password):
  30. <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
  31. </div>
  32. <br/>
  33. <div>Your #{config.product_name} Team</div>
  34. <br/>
  35. <div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
  36. 'recipient' => 'article_last_sender',
  37. 'subject' => 'Thanks for your inquiry (#{ticket.title})', # rubocop:disable Lint/InterpolationCheck
  38. },
  39. },
  40. active: true,
  41. created_by_id: 1,
  42. updated_by_id: 1,
  43. )
  44. Trigger.create_or_update(
  45. name: 'auto reply (on follow-up of tickets)',
  46. condition: {
  47. 'ticket.action' => {
  48. 'operator' => 'is',
  49. 'value' => 'update',
  50. },
  51. 'article.sender_id' => {
  52. 'operator' => 'is',
  53. 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id,
  54. },
  55. 'article.type_id' => {
  56. 'operator' => 'is',
  57. 'value' => [
  58. Ticket::Article::Type.lookup(name: 'email').id,
  59. Ticket::Article::Type.lookup(name: 'phone').id,
  60. Ticket::Article::Type.lookup(name: 'web').id,
  61. ],
  62. },
  63. },
  64. perform: {
  65. 'notification.email' => {
  66. 'body' => '<div>Your follow-up for <b>(#{config.ticket_hook}#{ticket.number})</b> has been received and will be reviewed by our support staff.</div>
  67. <br/>
  68. <div>To provide additional information, please reply to this email or click on the following link:
  69. <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
  70. </div>
  71. <br/>
  72. <div>Your #{config.product_name} Team</div>
  73. <br/>
  74. <div><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></div>',
  75. 'recipient' => 'article_last_sender',
  76. 'subject' => 'Thanks for your follow-up (#{ticket.title})', # rubocop:disable Lint/InterpolationCheck
  77. },
  78. },
  79. active: false,
  80. created_by_id: 1,
  81. updated_by_id: 1,
  82. )
  83. Trigger.create_or_update(
  84. name: 'customer notification (on owner change)',
  85. condition: {
  86. 'ticket.owner_id' => {
  87. 'operator' => 'has changed',
  88. 'pre_condition' => 'current_user.id',
  89. 'value' => '',
  90. 'value_completion' => '',
  91. }
  92. },
  93. perform: {
  94. 'notification.email' => {
  95. 'body' => '<p>The owner of ticket (Ticket##{ticket.number}) has changed and is now "#{ticket.owner.firstname} #{ticket.owner.lastname}".<p>
  96. <br/>
  97. <p>To provide additional information, please reply to this email or click on the following link:
  98. <a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}</a>
  99. </p>
  100. <br/>
  101. <p><i><a href="https://zammad.com">Zammad</a>, your customer support system</i></p>',
  102. 'recipient' => 'ticket_customer',
  103. 'subject' => 'Owner has changed (#{ticket.title})', # rubocop:disable Lint/InterpolationCheck
  104. },
  105. },
  106. active: false,
  107. created_by_id: 1,
  108. updated_by_id: 1,
  109. )