@robinpath/hubspot
0.1.1Node.jsPublicHubSpot module for RobinPath.
HubSpot
HubSpot module for RobinPath.
Package: @robinpath/hubspot | Category: Crm | Type: Integration
Authentication
hubspot.setToken "pat-xxx"
Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.
Use Cases
Use the hubspot module when you need to:
- Create a new contact in HubSpot. -- Use
hubspot.createContactto perform this operation - Get a contact by ID. -- Use
hubspot.getContactto perform this operation - Update a contact's properties. -- Use
hubspot.updateContactto perform this operation - List contacts with pagination. -- Use
hubspot.listContactsto perform this operation - Search contacts by query string. -- Use
hubspot.searchContactsto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
setToken | Set the HubSpot private app access token. | Confirmation message. |
createContact | Create a new contact in HubSpot. | Created contact object. |
getContact | Get a contact by ID. | Contact object. |
updateContact | Update a contact's properties. | Updated contact object. |
listContacts | List contacts with pagination. | Contacts list with paging. |
searchContacts | Search contacts by query string. | Search results. |
createDeal | Create a new deal in HubSpot. | Created deal object. |
getDeal | Get a deal by ID. | Deal object. |
updateDeal | Update a deal's properties. | Updated deal object. |
listDeals | List deals with pagination. | Deals list with paging. |
createCompany | Create a new company in HubSpot. | Created company object. |
getCompany | Get a company by ID. | Company object. |
Functions
setToken
Set the HubSpot private app access token.
Module: hubspot | Returns: string -- Confirmation message.
hubspot.setToken "pat-xxx"
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | HubSpot access token |
createContact
Create a new contact in HubSpot.
Module: hubspot | Returns: object -- Created contact object.
hubspot.createContact {"email":"john@example.com","firstname":"John","lastname":"Doe"}
| Parameter | Type | Required | Description |
|---|---|---|---|
properties | object | Yes | Contact properties (email, firstname, lastname, etc.) |
getContact
Get a contact by ID.
Module: hubspot | Returns: object -- Contact object.
hubspot.getContact "123"
| Parameter | Type | Required | Description |
|---|---|---|---|
contactId | string | Yes | Contact ID |
properties | array | No | Properties to return |
updateContact
Update a contact's properties.
Module: hubspot | Returns: object -- Updated contact object.
hubspot.updateContact "123" {"phone":"+1234567890"}
| Parameter | Type | Required | Description |
|---|---|---|---|
contactId | string | Yes | Contact ID |
properties | object | Yes | Properties to update |
listContacts
List contacts with pagination.
Module: hubspot | Returns: object -- Contacts list with paging.
hubspot.listContacts {"limit":10}
| Parameter | Type | Required | Description |
|---|---|---|---|
options | object | No | Options: limit, after, properties |
searchContacts
Search contacts by query string.
Module: hubspot | Returns: object -- Search results.
hubspot.searchContacts "john@example.com"
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search query |
options | object | No | Options: limit, properties, filterGroups |
createDeal
Create a new deal in HubSpot.
Module: hubspot | Returns: object -- Created deal object.
hubspot.createDeal {"dealname":"Big Deal","amount":"10000","dealstage":"appointmentscheduled"}
| Parameter | Type | Required | Description |
|---|---|---|---|
properties | object | Yes | Deal properties (dealname, amount, dealstage, etc.) |
getDeal
Get a deal by ID.
Module: hubspot | Returns: object -- Deal object.
hubspot.getDeal "456"
| Parameter | Type | Required | Description |
|---|---|---|---|
dealId | string | Yes | Deal ID |
properties | array | No | Properties to return |
updateDeal
Update a deal's properties.
Module: hubspot | Returns: object -- Updated deal object.
hubspot.updateDeal "456" {"amount":"20000"}
| Parameter | Type | Required | Description |
|---|---|---|---|
dealId | string | Yes | Deal ID |
properties | object | Yes | Properties to update |
listDeals
List deals with pagination.
Module: hubspot | Returns: object -- Deals list with paging.
hubspot.listDeals {"limit":10}
| Parameter | Type | Required | Description |
|---|---|---|---|
options | object | No | Options: limit, after, properties |
createCompany
Create a new company in HubSpot.
Module: hubspot | Returns: object -- Created company object.
hubspot.createCompany {"name":"Acme Inc","domain":"acme.com"}
| Parameter | Type | Required | Description |
|---|---|---|---|
properties | object | Yes | Company properties (name, domain, industry, etc.) |
getCompany
Get a company by ID.
Module: hubspot | Returns: object -- Company object.
hubspot.getCompany "789"
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId | string | Yes | Company ID |
properties | array | No | Properties to return |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
HubSpot: token not configured. Call hubspot.setToken first. | Check the error message for details |
HubSpot API error (${res.status}): ${text} | Check the error message for details |
hubspot.setToken requires a token. | Check the error message for details |
hubspot.createContact requires properties. | Check the error message for details |
hubspot.getContact requires a contactId. | Check the error message for details |
hubspot.updateContact requires contactId and properties. | Check the error message for details |
hubspot.searchContacts requires a query. | Check the error message for details |
hubspot.createDeal requires properties. | Check the error message for details |
@desc "Create contact and validate result"
do
set $result as hubspot.createContact {"email":"john@example.com","firstname":"John","lastname":"Doe"}
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. List and iterate Contact
Retrieve all items and loop through them.
@desc "Setup authentication"
do
hubspot.setToken $token
enddo
@desc "Get contact and iterate results"
do
set $result as hubspot.getContact "123"
each $item in $result
print $item
end
enddo
2. Create a new item with createContact
Create a new resource and capture the result.
@desc "Setup authentication"
do
hubspot.setToken $token
enddo
@desc "Create contact"
do
set $result as hubspot.createContact {"email":"john@example.com","firstname":"John","lastname":"Doe"}
print "Created: " + $result
enddo
3. Create and update workflow
Create an item and then update it.
@desc "Setup authentication"
do
hubspot.setToken $token
enddo
@desc "Create contact and update contact"
do
set $created as hubspot.createContact {"email":"john@example.com","firstname":"John","lastname":"Doe"}
# Update the created item
hubspot.updateContact "123" {"phone":"+1234567890"}
enddo
4. Check before creating
List existing items and only create if needed.
@desc "Setup authentication"
do
hubspot.setToken $token
enddo
@desc "Get contact and create contact"
do
set $existing as hubspot.getContact "123"
if $existing == null
hubspot.createContact {"email":"john@example.com","firstname":"John","lastname":"Doe"}
print "Item created"
else
print "Item already exists"
end
enddo
5. Multi-step HubSpot workflow
Chain multiple hubspot operations together.
@desc "Setup authentication"
do
hubspot.setToken $token
enddo
@desc "Create contact, get contact, and more"
do
set $r_createContact as hubspot.createContact {"email":"john@example.com","firstname":"John","lastname":"Doe"}
set $r_getContact as hubspot.getContact "123"
set $r_updateContact as hubspot.updateContact "123" {"phone":"+1234567890"}
print "All operations complete"
enddo
6. Safe createContact with validation
Check results before proceeding.
@desc "Setup authentication"
do
hubspot.setToken $token
enddo
@desc "Create contact and validate result"
do
set $result as hubspot.createContact {"email":"john@example.com","firstname":"John","lastname":"Doe"}
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- salesforce -- Salesforce module for complementary functionality
- pipedrive -- Pipedrive module for complementary functionality
- freshdesk -- Freshdesk module for complementary functionality
- intercom -- Intercom module for complementary functionality
- zoho -- Zoho module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
$ robinpath add @robinpath/hubspot
