Links

Update contact

Tags: #hubspot #crm #sales #contact #naas_drivers #snippet
Author: Florent Ravenel
Description: This notebook allows users to update contact information in HubSpot.

Input

Import libraries

from naas_drivers import hubspot
import naas

Setup HubSpot

👉 Starting November 30, 2022, HubSpot API keys no longer enable access to HubSpot APIs, so in Naas version 2.8.3 and above, you need create a private app and use the access token.
Enter Your Access Token
HS_ACCESS_TOKEN = naas.secret.get("HS_ACCESS_TOKEN") or "YOUR_HS_ACCESS_TOKEN"
Enter contact parameters to update
contact_id = "280751"
firstname = "Jean test"
lastname = "CASHSTOrY"
phone = "+336.00.00.00.00"
jobtitle = "Consultant"
website = "www.cashstory.com"
company = "CASHSTORY"
hubspot_owner_id = None

Model

Update contact using send method

This method will allow you to add any contact properties available in your HubSpot.
update_contact = {
"properties": {
"email": email,
"firstname": firstname,
"lastname": lastname,
"phone": phone,
"jobtitle": jobtitle,
"website": website,
"company": company,
"url": "test3",
"hubspot_owner_id": hubspot_owner_id,
}
}
contact_id1 = hubspot.connect(HS_ACCESS_TOKEN).contacts.patch(
contact_id, update_contact
)

Update contact using update method

contact_id2 = hubspot.connect(HS_ACCESS_TOKEN).contacts.update(
contact_id,
email,
firstname,
lastname,
phone,
jobtitle,
website,
company,
hubspot_owner_id,
)

Output

Display results

contact_id1
contact_id2