<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Associating an incoming email to a deal using custom code (Operations Hub) in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1030274#M76022</link>
    <description>&lt;P&gt;Thread ID is a property on the conversations object. As mentioned above, I pass that value to the custom code workflow as a parameter.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SteveHTM_0-1724251399890.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/125268iFE22A582A62B3306/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SteveHTM_0-1724251399890.png" alt="SteveHTM_0-1724251399890.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 14:43:56 GMT</pubDate>
    <dc:creator>SteveHTM</dc:creator>
    <dc:date>2024-08-21T14:43:56Z</dc:date>
    <item>
      <title>Associating an incoming email to a deal using custom code (Operations Hub)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1029575#M75973</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 12:40:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1029575#M75973</guid>
      <dc:creator>cargoplot</dc:creator>
      <dc:date>2024-08-20T12:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Associating an incoming email to a deal using custom code (Operations Hub)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1029929#M75995</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/272864"&gt;@cargoplot&lt;/a&gt;&amp;nbsp;- I use this kind of dynamic custom filtering of conversations a lot! The basis of the approach is to use a Conversations workflow and parse the internals of the Conversation object to get hold of the message details. Consider using a trigger criteria for the workflow which is tied to the Inbox ID and uses Source equal to Email. For the Custom code step, consider using ThreadID as a parameter and use the conversations/threads API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The structure is far from well documented, but essentially for inbound emails like this the data resolves into a series of MESSAGES where each message has structure for 'from', 'to', 'subject' etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck on this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 00:47:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1029929#M75995</guid>
      <dc:creator>SteveHTM</dc:creator>
      <dc:date>2024-08-21T00:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Associating an incoming email to a deal using custom code (Operations Hub)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1030056#M76006</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/63499"&gt;@SteveHTM&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply. Those are good tips. I am only wondering how I can get a thread ID from the conversations event data. I didn't see it when I inspected the fields of this object. Or did I miss it? And if I assign the thread to the deal, then all consequent emails in this thread will also be assigned to this deal?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 07:52:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1030056#M76006</guid>
      <dc:creator>cargoplot</dc:creator>
      <dc:date>2024-08-21T07:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Associating an incoming email to a deal using custom code (Operations Hub)</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1030274#M76022</link>
      <description>&lt;P&gt;Thread ID is a property on the conversations object. As mentioned above, I pass that value to the custom code workflow as a parameter.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SteveHTM_0-1724251399890.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/125268iFE22A582A62B3306/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SteveHTM_0-1724251399890.png" alt="SteveHTM_0-1724251399890.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 14:43:56 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Associating-an-incoming-email-to-a-deal-using-custom-code/m-p/1030274#M76022</guid>
      <dc:creator>SteveHTM</dc:creator>
      <dc:date>2024-08-21T14:43:56Z</dc:date>
    </item>
  </channel>
</rss>

