元問い合わせメールに返信したときの統合処理

元問い合わせメールに返信したときの統合処理

ワークフロー作成したので備忘録です。

Zoho Desk で作成したメールアドレス宛てに既存のメールアドレスにきた問合せ先メールを転送してチケット作成を行っています。
元の問い合わせメールに返信、転送した際にRe,RE,re,Fw,FW,fwが件名の頭に付くため、その度に新規起票が乱立します。

メールの頭にRe,RE,re,Fw,FW,fwがある時それを除いた件名と同じ件名が既にチケット作成されていれば統合するワークフローを作成しました。
条件が緩いので既存チケットの検索で完了済みや5日以上前に作成したものは除いてもいいとは思います。

【ワークフロー作成】

実行タイミング:作成する

条件: (1かつ(((2または3)または4)または5))

1、経路、が次の値と等しい、Email かつ
2、件名、が次の値で始まる、Re: または
3、件名、が次の値で始まる、RE: または
4、件名、が次の値で始まる、FW: または
5、件名、が次の値で始まる、Fw: 

処理
メソッド名:Tickets
1、ticketId、問い合わせ ID
2、subject、件名

  1. orgId = ;YourAPI
  2. // 組織ID

  3. // ====== Workflow Arguments ======
  4. // ticketId -> Ticket Id
  5. // subject  -> Subject
  6. newTicketIdText = ticketId.toString();
  7. newTicketId = ticketId.toLong();
  8. subjectText = ifnull(subject,"");
  9. originalSubject = subjectText.trim();
  10. info "New Ticket ID: " + newTicketIdText;
  11. info "Original Subject: " + originalSubject;
  12. if(originalSubject != "")
  13. {
  14. lowerOriginalSubject = originalSubject.toLowerCase();
  15. isReplyOrForward = false;
  16. if(lowerOriginalSubject.startsWith("re:") || lowerOriginalSubject.startsWith("fw:"))
  17. {
  18. isReplyOrForward = true;
  19. }
  20. if(isReplyOrForward == true)
  21. {
  22. // ====== prefix 除去処理 ======
  23. // RE: / FW: が複数重なっている場合も除去する
  24. // 例: "Re: FW: 問い合わせ" -> "問い合わせ"
  25. baseSubject = originalSubject;
  26. dummyList = "".leftpad(10).toList("");
  27. for each  dummy in dummyList
  28. {
  29. tempLower = baseSubject.toLowerCase().trim();
  30. if(tempLower.startsWith("re:"))
  31. {
  32. baseSubject = baseSubject.trim().subString(3).trim();
  33. }
  34. else if(tempLower.startsWith("fw:"))
  35. {
  36. baseSubject = baseSubject.trim().subString(3).trim();
  37. }
  38. }
  39. info "Base Subject: " + baseSubject;
  40. if(baseSubject != "")
  41. {
  42. // ====== 既存チケット検索 ======
  43. searchValue = Map();
  44. searchValue.put("subject",baseSubject);
  45. searchResponse = zoho.desk.searchRecords(orgId,"tickets",searchValue,0,100);
  46. info "Search Response:";
  47. info searchResponse;
  48. targetTicketId = null;
  49. targetTicketSubject = "";
  50. if(searchResponse != null && searchResponse.get("data") != null)
  51. {
  52. ticketList = searchResponse.get("data");
  53. for each  existingTicket in ticketList
  54. {
  55. existingTicketIdText = existingTicket.get("id").toString();
  56. // 自分自身は除外
  57. if(existingTicketIdText != newTicketIdText)
  58. {
  59. existingSubjectText = ifnull(existingTicket.get("subject"),"");
  60. existingSubject = existingSubjectText.trim();
  61. // 既存チケット側の件名にも RE:/FW: が付いていた場合は除去して比較
  62. normalizedExistingSubject = existingSubject;
  63. existingDummyList = "".leftpad(10).toList("");
  64. for each  existingDummy in existingDummyList
  65. {
  66. existingLower = normalizedExistingSubject.toLowerCase().trim();
  67. if(existingLower.startsWith("re:"))
  68. {
  69. normalizedExistingSubject = normalizedExistingSubject.trim().subString(3).trim();
  70. }
  71. else if(existingLower.startsWith("fw:"))
  72. {
  73. normalizedExistingSubject = normalizedExistingSubject.trim().subString(3).trim();
  74. }
  75. }
  76. info "Compare Existing Ticket: " + existingTicketIdText + " / " + normalizedExistingSubject;
  77. // prefix 除去後の件名が完全一致したら統合先にする
  78. if(normalizedExistingSubject == baseSubject)
  79. {
  80. targetTicketId = existingTicket.get("id").toLong();
  81. targetTicketSubject = existingSubject;
  82. break;
  83. }
  84. }
  85. }
  86. }
  87. if(targetTicketId != null)
  88. {
  89. // ====== チケット統合 ======
  90. // targetTicketId が親チケット
  91. // newTicketId が統合される新規チケット
  92. paramValue = {"ids":{newTicketId}};
  93. info "Merge new ticket " + newTicketIdText + " into existing ticket " + targetTicketId.toString();
  94. response = zoho.desk.ticket.merge(orgId,targetTicketId,paramValue);
  95. info "Merge Response:";
  96. info response;
  97. }
  98. else
  99. {
  100. info "No matching existing ticket found. Stop.";
  101. }
  102. }
  103. else
  104. {
  105. info "Base subject is empty after removing prefix. Stop.";
  106. }
  107. }
  108. else
  109. {
  110. info "Subject does not start with RE: or FW:. Stop.";
  111. }
  112. }
  113. else
  114. {
  115. info "Subject is empty. Stop.";
  116. }


        • Recent Topics

        • Change email addresses - Advise how

          Good day, I need assistance to change all our users email addresses Please advise
        • email signature

          How do you add an email signature
        • Email Forwarding | How to Enable and Disable Email Forwarding on a Non-Admin User Account

          Email Forwarding Issue: Enable and Disable Email Forwarding
        • Ask the Experts 31: Improving support performance with reports and dashboards

          Hello everyone, Join us for the next Ask the Experts (ATE) session! Ask the Experts is an opportunity to connect with people who have deep knowledge of Zoho Desk. Let's look at the topic we're focusing on this month. Just as we rely on the right tools
        • Zia AI capabilities now available in all paid editions

          Hello everyone, We are expanding the availability of AI-powered features in Desk to the other paid subscriptions from 7th July 2026. Right now, the following AI-based features are available for Enterprise edition users: Intelligence: Sentiment analysis,
        • Add a MATRIX field to the forms creation

          Same as Zoho forms, we need a Matrix field in Zoho Creator forms, is very usefull
        • Product updates in Zoho Workplace applications | June 2026

          Hello Workplace Community, Let’s take a look at the new features and enhancements that went live across all Workplace applications for the month of June. Zoho Mail Alphanumeric support for attachment extensions in rule conditions Attachment extension
        • Zoho support is trash

          I have been sending them requests for over two weeks and I get the most random off topic responses. What the hell is going on there? All I need is to get one of my users setup to run reports. Because as admin of the account I cannot even make this simple
        • Biggest supported size of a note

          I'm still testing this ZOho Notebook before purchasing a premium licence and can't work with large notes. I store personal vocabulary in two 13,000-word / 83200-character notes. Same poor experience with PC, Web, and mobile apps: Is there an application
        • I need help lease Email

          I' not getting an email replay when someone open a ticket
        • Sigma function call hangs forever from Desk widget — app_install_id/encapiKey are null

          Calling ZOHODESK.request() from the widget to invoke a Sigma DRE function URL hangs forever (never resolves, never rejects, no error) until client timeout. Tried with merge fields app_install_id={{sigmaInstallId}}/{{installationId}} and encapiKey={{enCapApiKey}}
        • Draft quotes, sales orders, and raise invoices for services in CRM

          Create Quotes, Sales Orders, and Invoices for Services in Zoho CRM You can now draft Quotes, and Sales Orders as well as raise Invoices for services in Zoho CRM. And how is that possible? By filling out the Service subform in your Quotes, Sales Orders
        • Canva Integration

          Hello! As many marketing departments are streamlining their teams, many have begun utilizing Canva for all design mockups and approvals prior to its integration into Marketing automation software. While Zoho Social has this integration already accomplished,
        • Admin Logging in as another User

          How can a Super Admin login as another user. For example, I have a sales rep that is having issues with their Accounts and I want to view their Zoho Account with out having to do a GTM and sharing screens. Latest Update (27th April 2026): With the early
        • Action Required: Allowlist New IP Ranges for the EU Data Center

          Dear Users, We are adding new IP ranges for the Zoho Analytics EU data center (https://analytics.zoho.eu). If you import data into Zoho Analytics from cloud databases (such as Amazon RDS, Amazon Redshift, or Microsoft Azure) or use Live Connect, you must
        • Tips & Tricks #3: Zoho CRM - Agentes en la página de inicio

          Hola a todos, Vuestros Agentes realizan un trabajo muy útil. Encuentran información como clientes potenciales importantes, oportunidades de venta y actualizaciones relevantes. Sin embargo, hasta ahora no era posible ver esa información directamente en
        • Pricelists

          So we have them in books but I cannot find them in commerce?
        • Automating CRM backup storage?

          Hi there, We've recently set up automatic backups for our Zoho CRM account. We were hoping that the backup functionality would not require any manual work on our end, but it seems that we are always required to download the backups ourselves, store them,
        • 'Pinned' notes feature of a pipeline record

          Hi team, Could you please implement a feature which will allow users to pin different notes so that they will appear at the very top of the notes tab in a pipeline record. Sometimes we have a wide range of notes on a record which means more important
        • Associate emails from both primary and secondary contacts to deal

          We need to associate emails from multiple contacts to a deal. Please advise how this can be achieved. At present, only emails from primary contacts can be associated. Thanks
        • Custom Button Creation from Layout Editor in Zoho CRM

          Hello All, Buttons in Zoho CRM act as triggers that perform a specific action when clicked. Zoho CRM includes a set of system buttons that help you carry out common actions with a single click. Beyond these, your organization can create custom buttons
        • #PitStop3: Share & Collect Payment using Zoho Invoice

          We have reached another milestone in our journey. Post #15 to #20 weren't just about sharing invoices, they were about building a payment workflow that works for you, your customers and your business. Here's a quick wrap of what we covered in this segment:
        • Suggestions for Improving the Deluge Development Experience

          Hello, I would like to share some ideas that could significantly improve the Deluge development experience, especially for partners and developers building larger solutions across the Zoho ecosystem. Some key areas that would add a lot of value: Deluge
        • Enhancement announcement: Mitigate mailbox clutter using the new field: "Sync emails from"

          Dear Customers, We hope you're well! We are here with a minor enhancement in email integration in Zoho CRM. Emails have become the primary mode of communication these days. Because of which mailboxes are getting overly cluttered day after day. To help
        • Zoho CRM Sandbox now supports integrations

          Hello everyone, We are now expanding Zoho CRM Sandbox to support integrations with other Zoho products. You can connect, configure, and validate the behavior of your integrated tools within a safe, isolated environment - testing end-to-end without touching
        • Building Toppings #8 - Using widgets to extend the Bigin UI

          Hello Biginners, In our previous forum post, we explored schedules and workflow functions and learned how to automate real-time and time-based actions inside a topping. In this post we'll look at how to embed custom UI components inside Bigin using widgets.
        • Tip #81 – Turn every session into a story with Session Highlights – 'Insider Insights'

          Hello Zoho Assist Community! Picture this: your team wraps up dozens of remote support sessions every week. Each one involved troubleshooting, tools, fixes, and back-and-forth with customers. But when it's time to review what actually happened across
        • Zoho CRM APIs

          Hello, I think as a developer, it is very important to have the ability to manage, develop, and execute functions directly from my local development environment (for example, VS Code). Zoho CRM should have a way to create, deploy, and manage functions
        • 🎙️ Ask The Experts: Get Your Bigin Questions Answered Live

          We've seen so many thoughtful questions from our #BiginnersClub community over the years. While we're always happy to help here, we're excited to introduce a new way for you to connect with us directly. Join us for Ask The Experts, a one-hour live fireside
        • Postcode problems

          So we were very pleased to see we could limit shipping with postcodes. Brilliant. Unfortunately we have discovered It does not seem fit for purpose. In the UK we write postcodes in various ways Examples BH217NL BH21 7NL Bh217nl bh217NL and many more ways
        • Certain items certain shipping

          Me again it would be helpful to have different shipping for different categories. Our example are salt. Delivery is free but have a minimum delivery. Pickup is cheaper so it has its own category- pickup.
        • Cookies Consent Management in Webforms

          Hello Everyone! We are excited to introduce Cookie Consent Management for webforms. Read on to learn more. Webforms are online forms embedded on websites that allow users to submit data and create records in Zoho CRM. These forms utilize cookies to track
        • Payment links in Bigin just got supercharged

          Greetings, We're happy to announce major enhancements to the Payments feature in Bigin. As you may already know, Bigin supports Payments integration, which enables you to create and send payment links directly from Bigin to your customers. It also allows
        • Disable Spam filter

          Hi Support Team, Please disable spam filter for https://desk.zoho.in/support/keboli. Some spam ticket ids: #102, #103, #104
        • I just signed up

          Hi, I have just signed up for the domain griffithcgenterprises.com. I would like to make two adjustments: If possible, I would prefer a 5 GB hosting/email plan instead of the current 10 GB option, as I believe that should be sufficient for my needs at
        • History tab stuck loading indefinitely on Android (v2.22.0)

          History tab stuck loading indefinitely on Android (v2.22.0) — server returns 500 on visitorhistoryviews Hi all, I'm running into an issue where the History tab in the SalesIQ Android app (v2.22.0) never loads — it just spins indefinitely. Screenshots
        • Não consigo enviar e receber e-mail

          Estou tendo problema de envio e recebimento de e-mail (meu e-mail é ands....lisi.com.br) Esta mensagem foi criada automaticamente pelo software de entrega de e-mails. Uma mensagem que você enviou não pôde ser entregue a um ou mais destinatários. Este
        • إلغاء الإشتراك

          أريد إلغاء الإشتراك نهائياً.
        • Opening two notes at once in the Mac app

          Just like the title says - I want two notes open the same time on my Mac Air. AI search seems to think I have the option to open one window, then click on a second one. But of course if one window is open I can't see the others. It also recommended using
        • Introducing the Employee Portal for internal job posting

          Employee referrals and internal applications are one of the most trusted hiring channels. But in many organizations, employees only hear about openings through messages, word of mouth, or after the role has already been open for a while. When employees
        • Next Page