Email Polling System

Introduction

In this guide, you’ll learn how to set up an email polling system that periodically fetches emails and completes assignments based on your configurations in Joget. This system helps automate processes by handling responses received via email.

Note:
Ensure to create a dedicated email address for receiving response emails to avoid processing irrelevant messages.

How does it work?

  1. Each listener in Joget acts as a process instance that runs in a loop until terminated by the user. You can configure multiple listeners to handle different email sources.
  2. Configure IMAP Email Settings to specify which email inbox the system should monitor for incoming messages.
  3. Set up Listener Settings to define how frequently the system checks for new emails and specify the matching patterns.
    Note that the checking interval is also subjected to the Deadline Checker interval set in Joget DX8's system settings. Please ensure the Process Deadline Checker Interval is enabled. This can be located at Admin Bar > General Settings > Timer Settings > Process Deadline Checker Interval.
  4. Ensure that your email content patterns match the emails sent by Joget DX8. Use debug mode to verify patterns and troubleshoot if necessary.


    Content Pattern
    {form_approval_new_application_approval_action_status}
    {unuse}
    {unuse}ID: {processId}
    {unuse}Remarks: [{form_approval_new_application_approval_action_remarks}]
    {unuse}

    You may be wondering where does {form_approval_new_application_approval_action_status} comes from. It is actually the field element name of said field. Just use the Inspect Element feature in your browser to acquire the field element name and add the prefix "form_" to it. (see sample screenshot below) This will retrieve the value in the email content and set it into the form data. 

    • Example of an email configured in the Email Tool to be sent from the system to the respondent.
      The following application required your approval with details:
      ====================================
      Name : #form.seaa_application.name#
      Email : #form.seaa_application.email#
      ID: #assignment.processId#
      ====================================
      Please reply this email with keyword "Approved", "Rejected" or "Clarification Required".
      If your have remark message, please fill inline between the square brackets below.
      Remarks: [ ]
      ==  This is a system generated message. ==
    • Example email will be displayed as such
      The following application required your approval with details:
      ====================================
      Name : Etta
      Email : etta@joget.com
      ID: 43_seaa_new_application_approver_process
      ====================================
      Please reply this email with keyword "Approved", "Rejected" or "Clarification Required".
      If your have remark message, please fill inline between the square brackets below.
      Remarks: []
      ==  This is a system generated message. ==
    • Example email replied to by the receiver back to the mailer.
      Approved
       
      > The following application required your approval with details:
      > ====================================
      > Name : Etta
      > Email : etta@joget.com
      > ID: 43_seaa_new_application_approver_process
      > ====================================
      > Please reply this email with keyword "Approved", "Rejected" or "Clarification Required".
      > If your have remark message, please fill inline between the square brackets below.
      > Remarks: [356pm approved]
      > ==  This is a system generated message. ==
    • Server log showing email polling and assignment completion.
      INFO  02 Mar 2016 16:52:50 App: eas - Poll Email tool  - Connect to IMAP for machine@sample-joget.com
      INFO  02 Mar 2016 16:52:53 App: eas - Poll Email tool  - IMAP connected for machine@sample-joget.com
      INFO  02 Mar 2016 16:52:53 App: eas - Poll Email tool  - Unread Messages: 1
      INFO  02 Mar 2016 16:52:54 App: eas - Poll Email tool  - Subject filter for (Re: Email Approval).
      INFO  02 Mar 2016 16:52:55 App: eas - Poll Email tool  - --- Mail 0: Re: Email Approval ---
      INFO  02 Mar 2016 16:52:55 App: eas - Poll Email tool  - Sender: Cat Grant <cat-grant@sample-joget.com>
      INFO  02 Mar 2016 16:52:55 App: eas - Poll Email tool  - Mail Content: Approved____> The following application required your approval with details:__> ====================================__> Name : Etta__> Email : etta@joget.com__> ID: 43_seaa_new_application_approver_process__> ====================================__>__> Please reply this email with keyword "Approved", "Rejected" or "Clarification Required".__>__> If your have remark message, please fill inline between the square brackets below.__> Remarks: [356pm approved]__>__> ==  This is a system generated message. ==__>__>__
      INFO  02 Mar 2016 16:52:55 App: eas - Poll Email tool  - subject_pattern:
      INFO  02 Mar 2016 16:52:55 App: eas - Poll Email tool  - subject_reg:
      INFO  02 Mar 2016 16:52:55 App: eas - Poll Email tool  - subject_reg:
      INFO  02 Mar 2016 16:52:55 App: eas - Poll Email tool  - content_pattern: {form_approval_new_application_approval_action_status}__{unuse}__{unuse}ID: {processId}__{unuse}Remarks: [{form_approval_new_application_approval_action_remarks}]__{unuse}__
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - content_reg: \{form_approval_new_application_approval_action_status\}__\{unuse\}__\{unuse\}ID: \{processId\}__\{unuse\}Remarks: \[\{form_approval_new_application_approval_action_remarks\}\]__\{unuse\}__
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - content_reg: (.*?)__([\s\S]*)__([\s\S]*)ID: (.*?)__([\s\S]*)Remarks: \[(.*?)\]__([\s\S]*)__
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - key: form_approval_new_application_approval_action_status
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - value: Approved
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - key: unuse
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - value: __> The following application required your approval with details:__> ====================================__> Name : Etta__> Email : etta@joget.com
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - key: unuse
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - value: >
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - key: processId
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - value: 43_seaa_new_application_approver_process
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - key: unuse
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - value: > ====================================__>__> Please reply this email with keyword "Approved", "Rejected" or "Clarification Required".__>__> If your have remark message, please fill inline between the square brackets below.__>
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - key: form_approval_new_application_approval_action_remarks
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - value: 356pm approved
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - key: unuse
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - value: >__> ==  This is a system generated message. ==__>__>
      INFO  02 Mar 2016 16:52:56 App: eas - Poll Email tool  - Submit Form for assignment: 81_43_seaa_new_application_approver_process_approval {approval_new_application_approval_action_status=[Ljava.lang.String;@e992653, approval_new_application_approval_action_remarks=[Ljava.lang.String;@68a31aa1}
      I
  5. If there is a match based on the subject or the content, the code block will retrieve the email's sender information (email) and match it with an existing user in the system.

    If there's a match with a user and a further match with the particular user's assignment, then it will proceed to complete the assignment.

    Depending on the configurations set, workflow variables' values and/or form data values can also be set while completing the assignment.

Related documentation

Created by Julieth Last modified by Aadrian on Dec 13, 2024