Links

Create contact

Tags: #hubspot #crm #sales #contact #naas_drivers #snippet
Author: Florent Ravenel
Description : This notebook create a deal 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
firstname = "Test"
lastname ='CASHSTORY'
phone = "+33600000000"
jobtitle = "Consultant"
website = "www.cashstory.com"
company = 'CASHSTORY'
hubspot_owner_id = None

Model

Create contact using send method

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

Create contact using create method

contact2 = hubspot.connect(HS_ACCESS_TOKEN).contacts.create(
email,
firstname,
lastname,
phone,
jobtitle,
website,
company,
hubspot_owner_id
)

Output

Display results

contact1
contact2