Create deal
Tags: #hubspot #crm #sales #deal #naas_drivers
Author: Florent Ravenel

Input

Import library

1
from naas_drivers import hubspot
Copied!

Setup your HubSpot

👉 Access your HubSpot API key
1
HS_API_KEY = 'YOUR_HUBSPOT_API_KEY'
Copied!

Enter deal parameters

1
dealname = "TEST"
2
closedate = None #must be in format %Y-%m-%d
3
amount = None
4
hubspot_owner_id = None
Copied!

Enter deal stage ID

1
df_pipelines = hubspot.connect(HS_API_KEY).pipelines.get_all()
2
df_pipelines
Copied!
1
dealstage = '5102584'
Copied!

Model

Create deal

Using send method

1
send_deal = {"properties":
2
{
3
"dealstage": dealstage,
4
"dealname": dealname,
5
"amount": amount,
6
"closedate": closedate,
7
"hubspot_owner_id": hubspot_owner_id,
8
}
9
}
10
11
deal1 = hubspot.connect(HS_API_KEY).deals.send(send_deal)
Copied!

Using create method

1
deal2 = hubspot.connect(HS_API_KEY).deals.create(
2
dealname,
3
dealstage,
4
closedate
5
)
Copied!

Output

Display results

1
deal1
Copied!
1
deal2
Copied!
Copy link
Edit on GitHub