We recently upgraded to operations hub pro and service hub pro. I was told this would give me the ability to have more control over how incoming emails are associated to deals, particularly via custom code.
Basically my problem is the following. All emails we send out contain a specific reference (e.g. C434-XRB2) in the subject line. This same reference is present in the deal name. Whenever an email comes in, I want to scan its subject line for a reference (using a regex or something) and then search if there are any deals present with this reference. If so, I want to associate the email with the matching deals.
I have made a first attempt using custom code workflows in operations hub, but I get stuck by my lack of knowledge of Hubspot internal structure. Particularly, what entity should trigger the workflow? The creation of a conversation, or at ticket? There doesn’t appear to be a specific trigger for emails.
If the conversation is the trigger, how do I retrieve the specific email to scan its subject? The event contains an objectId, but the conversations API is still in Beta, and doesn’t appear to offer a way to retrieve an email simply by an objectId; you need a thread id as well.
In short, is there anyone that can help me on my way with this, or give some pointers on what is the best way to start? Many thanks!
