Re: Copy contact properties to Deal?
01-04-2018 01:20 - edited 01-09-2018 05:08
Happy to share what I've designed for my client in the hopes it helps you.
Objective: copy contact properties into newly created deal
- Given that HubSpot does not natively support this feature, the below solution requires some minor custom code (which I've shared) and one external service provider (Zapier) to connect all the dots. You can technically integrate without Zapier, but that requires more engineering efforts and is outside the scope of what I'm summarizing below since I don't think that's what either of you is looking for.
- I've identified two ways of successfully copying contact properties into deal properties. Depending on how important speed is for your application (ie. do you need the deal properties updated instantly when deal is created, or are you okay waiting upwards of 5 to 15 minutes) you can decide which approach is right for you.
Option 1 (not instant):
- Within Zapier, click "Make a Zap!" and select HubSpot CRM as Trigger app
- Next, select "New Deal" as the trigger (this will run either every 15 or 5 min depending on your Zapier account)
- If it's not already, connect your correct HubSpot account on the next page by entering your username / password in the popup after selecting "Connect Account"
- After connecting your HubSpot account, make sure you've created a recent deal before testing the connection in the next step within Zapier
- Assuming you've created a new deal, Zapier will identify the deal. In the response object, you will see "associatedVids" property. Provided you have associated the proper contact with deal, this is the HubSpot contact ID. We will use it in next request.
- We will now use this returned 'associatedVids' value to make a follow up call to HubSpot to retrieve the desired contact property values we want to copy into deal
- In the "Action" step within Zapier, select "Code" option (note: do not select "HubSpot CRM" and "Find Contact" because it will force you to search by name or email address - neither of these values is included with Deal properties by default and would add complexity to your internal (human) system process when creating deals).
- After selecting "Code" select "Run Python" (don't worry if you're not an engineer, I'll provide code below)
- In the next field, enter the following values
url = 'https://api.hubapi.com/contacts/v1/contact/vid/%s/profile?hapikey=[enter your HubSpot API key here]' % (input_data['vid'])
response = requests.get(url)
- Be sure to update the above request with your own HubSpot API key. Once you've done so, run the test and you should see the test was successful provided your API key is entered correctly.
- Now that we have our Contact Properties being returned, our final step is to setup a second Action within Zapier to update an existing deal with these property values.
- On the left side of Zapier screen, select the "+" button underneath the first action we just created. Select "HubSpot CRM" as the App and "Update Deal" as the Action.
- Next, select the HubSpot account that you recently added that has the deal. Next to the Deal parameter, select the downward arrow, scroll to the bottom and select "Use Custom Value"
- A new field will appear directly below called "Custom Value for Deal Deal ID". Select the + arrow on the right of this field and select "Deal ID" which will be listed under the results from Step 1
- Next, identify the Deal Properties you want to automatically update to include values from Contact Properties. Select the "+" icon on the right side of these input fields and locate the returned corresponding Contact Property values which will be listed underneath the "2: Run Python" header in dropdown. This simple process maps the returned values in our Python request to the Deal Property fields when we make the API call to HubSpot.
- When you're done mapping the Deal Properties you'd like updated, scroll to the bottom and select "Continue"
- On the next screen, Zapier will show you the sample values they will be using to make test call to HubSpot CRM. If everything looks correct and no errors are reported, run the test. If everything is setup properly, this test will update the Deal in HubSpot. Check HubSpot to confirm your deal properties are updated.
- Last, turn on your Zap! By default, it will run every 15 minutes unless you upgrade your Zapier account and it will then run every 5 minutes.
Please let me know if updating Deal Properties instantly when Deal is created is important for your use cases and I will then document how you can make that happen. It will require slightly more work, on your end (and mine to document), but happy to help. And it won't require updating your Zapier account for just this purpose.