|
| 1 | +# HubSpot Action |
| 2 | + |
| 3 | +HubSpot CRM integration for the **Hercules** automation platform. Lets flows |
| 4 | +react to HubSpot webhook events and create, update, search, associate, and |
| 5 | +annotate CRM records through the official |
| 6 | +[`@hubspot/api-client`](https://www.npmjs.com/package/@hubspot/api-client) SDK |
| 7 | +(HubSpot CRM v3 API). |
| 8 | + |
| 9 | +## Configuration |
| 10 | + |
| 11 | +Configured via the action's `ConfigurationDefinition`s: |
| 12 | + |
| 13 | +| Identifier | Type | Required | Description | |
| 14 | +|------------|------|----------|-------------| |
| 15 | +| `access_token` | TEXT | yes | Private-app access token (Bearer) for the HubSpot CRM API. | |
| 16 | +| `app_id` | TEXT | no | HubSpot app id, used when managing webhook subscriptions. | |
| 17 | +| `client_secret` | TEXT | no | HubSpot app client secret, used to validate the `X-HubSpot-Signature` on inbound webhooks. | |
| 18 | + |
| 19 | +Beyond the shared Hercules variables (`HERCULES_AUTH_TOKEN`, |
| 20 | +`HERCULES_AQUILA_URL`, `HERCULES_ACTION_ID`, `HERCULES_SDK_VERSION`), the only |
| 21 | +provider-specific credential required is the HubSpot private-app access token. |
| 22 | + |
| 23 | +### Creating a private app |
| 24 | + |
| 25 | +1. In HubSpot, go to **Settings → Integrations → Private Apps**. |
| 26 | +2. Create a private app and grant the CRM scopes you need |
| 27 | + (`crm.objects.contacts.*`, `crm.objects.deals.*`, `crm.objects.companies.*`, |
| 28 | + `crm.schemas.*`, and note/engagement scopes for `hubspotAddNote`). |
| 29 | +3. Copy the access token into the action's `access_token` config. |
| 30 | + |
| 31 | +### Webhooks (triggers) |
| 32 | + |
| 33 | +The triggers use the shared `Rest` (webhook) event pattern. Point a HubSpot app |
| 34 | +**webhook subscription** at the URL generated for the trigger. HubSpot delivers |
| 35 | +a JSON array of change events; each event is exposed to the flow as a |
| 36 | +`HUBSPOT_WEBHOOK_EVENT`. To verify signatures, configure `client_secret`. |
| 37 | + |
| 38 | +## Triggers |
| 39 | + |
| 40 | +| Identifier | Fires on | |
| 41 | +|------------|----------| |
| 42 | +| `HubSpotContactCreatedWebhook` | `contact.creation` | |
| 43 | +| `HubSpotDealCreatedWebhook` | `deal.creation` | |
| 44 | +| `HubSpotDealStageChangedWebhook` | `deal.propertyChange` on `dealstage` | |
| 45 | +| `HubSpotFormSubmittedWebhook` | form submission (lead capture) | |
| 46 | + |
| 47 | +## Functions |
| 48 | + |
| 49 | +| Identifier | Signature | Description | |
| 50 | +|------------|-----------|-------------| |
| 51 | +| `hubspotCreateContact` | `(Email, PropertiesJson?): HUBSPOT_CONTACT` | Create a contact. | |
| 52 | +| `hubspotUpdateContact` | `(ContactId, PropertiesJson): HUBSPOT_CONTACT` | Update a contact. | |
| 53 | +| `hubspotGetContactByEmail` | `(Email): HUBSPOT_CONTACT` | Look up a contact by email. | |
| 54 | +| `hubspotCreateDeal` | `(Name, Pipeline, Stage, Amount?, PropertiesJson?): HUBSPOT_DEAL` | Create a deal. | |
| 55 | +| `hubspotUpdateDeal` | `(DealId, PropertiesJson): HUBSPOT_DEAL` | Update a deal. | |
| 56 | +| `hubspotCreateCompany` | `(Name, PropertiesJson?): HUBSPOT_COMPANY` | Create a company. | |
| 57 | +| `hubspotAddNote` | `(Body, PropertiesJson?): HUBSPOT_NOTE` | Create a note engagement. | |
| 58 | +| `hubspotAssociate` | `(FromObjectType, FromId, ToObjectType, ToId): BOOLEAN` | Create the default association between two objects. | |
| 59 | +| `hubspotSearchObjects` | `(ObjectType, Query): HUBSPOT_SEARCH_RESULT` | Full-text search a CRM object type. | |
| 60 | + |
| 61 | +### Property maps |
| 62 | + |
| 63 | +HubSpot CRM properties are a dynamic key/value bag, so functions accept extra |
| 64 | +properties as a **JSON object string** (e.g. |
| 65 | +`{"firstname":"Ada","lifecyclestage":"lead"}`) rather than a fixed set of typed |
| 66 | +parameters. Values are coerced to strings, matching the HubSpot API. |
| 67 | + |
| 68 | +## Data types |
| 69 | + |
| 70 | +`HUBSPOT_CONTACT`, `HUBSPOT_DEAL`, `HUBSPOT_COMPANY`, `HUBSPOT_NOTE` (all share |
| 71 | +the SDK's `SimplePublicObject` envelope: `id`, `properties`, timestamps, |
| 72 | +`archived`), plus `HUBSPOT_SEARCH_RESULT` and `HUBSPOT_WEBHOOK_EVENT`. |
| 73 | + |
| 74 | +## Development |
| 75 | + |
| 76 | +```bash |
| 77 | +npm install |
| 78 | +npm run typecheck |
| 79 | +npm run build |
| 80 | +npm run test |
| 81 | +``` |
0 commit comments