Links

Get contact from URL

Tags: #hubspot #crm #sales #contact #naas_drivers #snippet #dataframe
Author: Florent Ravenel
Description : This notebook get a contact from HubSpot using its URL. Data will be returned as json with keys:
  • 'id': number,
  • 'properties': dict
  • 'createdAt': datetime
  • 'updatedAt': datetime
  • 'archived': boolean

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 your Contact URL
contact_url = "ENTER_CONTACT_URL_HERE" # EXAMPLE : "https://app.hubspot.com/contacts/0000011/contact/00001"
Enter your Contact properties
List of properties you want to get from contact. By default, you will get:
  • email
  • firstname
  • lastname
  • createdate
  • lastmodifieddate
  • hs_object_id
properties = []

Model

Split contact URL to get contact ID

contact_id = contact_url.split("/contact/")[-1]

Get single contact

contact = hubspot.connect(HS_ACCESS_TOKEN).contacts.get(contact_id)

Output

Display result

contact