Links

Send deals to gsheet

Tags: #hubspot #crm #sales #deal #naas_drivers #gsheet #snippet #googlesheets
Author: Florent Ravenel
Last update: 2023-04-12 (Created: 2022-02-21)
Description: This notebook allows you to send HubSpot deals to a Google Sheet for easy tracking and analysis.

Input

Import libraries

from naas_drivers import hubspot, gsheet
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 Deal properties
List of properties you want to get from deal. By default, you will get:
  • dealname
  • amount
  • dealstage
  • pipeline
  • createdate
  • closedate
  • hs_object_id
  • hs_lastmodifieddate
properties = []

Setup your Google Sheets

Pre-requisite: share your Google Sheets with our service account: 🔗 [email protected]
SPREADSHEET_URL = "ENTER_YOUR_SPREADSHEET_URL_HERE"
SHEET_NAME = "ENTER_YOUR_SHEET_NAME_HERE"

Model

Get deals

df_deals = hubspot.connect(HS_ACCESS_TOKEN).deals.get_all(properties)

Output

Send contacts to gsheet

gsheet.connect(SPREADSHEET_URL).send(sheet_name=SHEET_NAME, data=df_deals, append=False)