Importing emails automatically

That’s the kind of precise logic I was asking for. Pseudo-code that can be used to produce code.

Another condition must be added: what if there is more than one match with the email address?

Updated. I propose first try to find a Contact with this incoming message’s Email Address, and if found, set that Contact as the parent of this imported email.
Next, if there was no Contact, then search for this Email Address, it can be related to any module… Leads, Opportunities, Targets, Accounts, any module. The first one that is found, would be assigned as the parent of this imported email.
Further refinement, there could be a default sort order for which module you prefer to relate imported email to.
Yet more refinement, each group inbox could have an ordered list of modules that imported emails would search in order to find the related module record.
For example, sales@... group inbox could be set to relate incoming emails to the sales group of modules (Contacts, Accounts, Opportunities, etc).
info@... group inbox could be set to relate to the Marketing group of modules (Targets, Leads, etc).

Cool.

Still, I think both those Yes/No need to be expanded into a “No/One/Multiple”

That’s because (I think) you can have the same address stored in many records of the same type.

In CRM I developed many years ago, which was IBM Notes based, there was a duplicate control implemented - accounts and contacts could not share the same email addresses. They had one main email plus aliases, but all of them had to be unique. The Notes CRM database could serve as a regular address book for the organization, and it was the other reason why it had to control the uniqueness.

It should pick a parent module record with a matching email address, at bare minimum. Because by not picking one, the email fails to display in the UI, the user experience is ruined with no explanation why, and no possibility for the user to select a module record as the parent of the email, so that it will then display in the UI.

You’re correct. It should find matching contact or other record with email address. It is better than looking at blank screen on the website :upside_down_face: :face_with_peeking_eye:

Yes, but how would you pick one of there are several?

Here’s how Suite will pick the most correct parent module record, for every auto imported email message. Note, this requires a code update:

  1. From now on, when Suite sends out an email message to a person in the CRM (target, lead, contact, account, etc), Suite must first add a custom header to the email message:
    X-Suite-Parent-ID: 88888888-4444-4444-4444-cccccccccccc - the UUID of the parent module record, which this email message is related to.
  2. When the person replies to the email message, Suite will receive the header as part of this reply email. From now on, Suite must read the value from header X-Suite-Parent-ID and set it into the parent_id when importing the email automatically.
  3. If there is no header X-Suite-Parent-ID, or no valid value from the header X-Suite-Parent-ID:
    a. If the From email address from the email message does not exist in the CRM, or exists and is related to (used by) 0 module records, then create a new Lead and set the value of this new Lead’s UUID into the value of the auto imported email’s parent_id.
    b. If the From email address from the email message exists in the CRM, and is used 1 time, then set the module record related to this email address, as the parent_id of the auto imported email message.
    c. If the From email address from the email message exists in the CRM, and is used more than 1 module record, then use a default rule (first Contact type record, if any, then first Lead, then first Target, then go thru all modules until one matches) to pick which module record ID to set.as the parent_id of the auto imported email message.
1 Like