Modules@robinpath/hubspot
hubspot

@robinpath/hubspot

0.1.1Node.jsPublic

HubSpot 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.createContact to perform this operation
  • Get a contact by ID. -- Use hubspot.getContact to perform this operation
  • Update a contact's properties. -- Use hubspot.updateContact to perform this operation
  • List contacts with pagination. -- Use hubspot.listContacts to perform this operation
  • Search contacts by query string. -- Use hubspot.searchContacts to perform this operation

Quick Reference

FunctionDescriptionReturns
setTokenSet the HubSpot private app access token.Confirmation message.
createContactCreate a new contact in HubSpot.Created contact object.
getContactGet a contact by ID.Contact object.
updateContactUpdate a contact's properties.Updated contact object.
listContactsList contacts with pagination.Contacts list with paging.
searchContactsSearch contacts by query string.Search results.
createDealCreate a new deal in HubSpot.Created deal object.
getDealGet a deal by ID.Deal object.
updateDealUpdate a deal's properties.Updated deal object.
listDealsList deals with pagination.Deals list with paging.
createCompanyCreate a new company in HubSpot.Created company object.
getCompanyGet 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"
ParameterTypeRequiredDescription
tokenstringYesHubSpot 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"}
ParameterTypeRequiredDescription
propertiesobjectYesContact properties (email, firstname, lastname, etc.)

getContact

Get a contact by ID.

Module: hubspot | Returns: object -- Contact object.

hubspot.getContact "123"
ParameterTypeRequiredDescription
contactIdstringYesContact ID
propertiesarrayNoProperties to return

updateContact

Update a contact's properties.

Module: hubspot | Returns: object -- Updated contact object.

hubspot.updateContact "123" {"phone":"+1234567890"}
ParameterTypeRequiredDescription
contactIdstringYesContact ID
propertiesobjectYesProperties to update

listContacts

List contacts with pagination.

Module: hubspot | Returns: object -- Contacts list with paging.

hubspot.listContacts {"limit":10}
ParameterTypeRequiredDescription
optionsobjectNoOptions: limit, after, properties

searchContacts

Search contacts by query string.

Module: hubspot | Returns: object -- Search results.

hubspot.searchContacts "john@example.com"
ParameterTypeRequiredDescription
querystringYesSearch query
optionsobjectNoOptions: 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"}
ParameterTypeRequiredDescription
propertiesobjectYesDeal properties (dealname, amount, dealstage, etc.)

getDeal

Get a deal by ID.

Module: hubspot | Returns: object -- Deal object.

hubspot.getDeal "456"
ParameterTypeRequiredDescription
dealIdstringYesDeal ID
propertiesarrayNoProperties to return

updateDeal

Update a deal's properties.

Module: hubspot | Returns: object -- Updated deal object.

hubspot.updateDeal "456" {"amount":"20000"}
ParameterTypeRequiredDescription
dealIdstringYesDeal ID
propertiesobjectYesProperties to update

listDeals

List deals with pagination.

Module: hubspot | Returns: object -- Deals list with paging.

hubspot.listDeals {"limit":10}
ParameterTypeRequiredDescription
optionsobjectNoOptions: 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"}
ParameterTypeRequiredDescription
propertiesobjectYesCompany properties (name, domain, industry, etc.)

getCompany

Get a company by ID.

Module: hubspot | Returns: object -- Company object.

hubspot.getCompany "789"
ParameterTypeRequiredDescription
companyIdstringYesCompany ID
propertiesarrayNoProperties to return

Error Handling

All functions throw on failure. Common errors:

ErrorCause
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)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/hubspot

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size5.3 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

sales