Docs

HubSpot

Connect HubSpot with a service key: referred people appear in HubSpot with the partner who sent them, and a deal you win pays that partner on the deal’s amount.

The HubSpot connection works in both directions:

  • To HubSpot: each person a partner refers is created or updated as a HubSpot contact, by email, with the contact property Affiligato partner set to the partner’s name and id.
  • From HubSpot: when a deal reaches a won stage and one of its contacts is a person Affiligato sent, the partner who referred that person earns commission on the deal’s amount, through your commission rules.

With HubSpot connected, you do not record those payments by hand. See Quotes and invoices for the rest of the setup.

Connect

Connect in the dashboard, so the key goes from HubSpot to Affiligato and never passes through an AI agent. An agent can call get_integrations to see whether HubSpot is connected, and why a broken connection stopped.

  1. Create a service key in HubSpot

    Open Development → Keys → Service keys and create a key with these scopes: crm.objects.contacts.read, crm.objects.contacts.write, crm.objects.deals.read and crm.schemas.contacts.write. Copy the key; it starts with pat-.

  2. Paste it into Affiligato

    Open Settings → Connect → HubSpot, paste the key into Service key and choose Connect HubSpot.

Affiligato checks the key, creates the contact property affiligato_partner (label Affiligato partner) if it does not exist, and keeps the key encrypted. The panel then shows the HubSpot account id and the currency that deals without their own currency count in: the account’s company currency.

What goes to HubSpot

  • While HubSpot is connected, a person is sent when they become a referral and when their customer record changes. Affiligato creates or updates the contact with that email and sets Affiligato partner to the partner’s name followed by their id in brackets. It writes no other property.
  • Contacts are sent in batches, about once a minute. A batch HubSpot does not accept is tried again later, up to eight times.
  • People referred before you connected are not sent when you connect.
  • Sample partners and demo programs are never sent.

Won deals

About once a minute, Affiligato reads the deals that changed since its last read, starting from the moment you connected.

  • A deal counts as won when its stage is one HubSpot marks closed with a probability of 100%, in any pipeline. The stage’s name does not matter.
  • It pays only when one of the deal’s contacts is a person Affiligato sent to HubSpot. The partner who referred that person earns. A deal with no such contact is left alone.
  • The sale is the deal’s amount, in the deal’s currency, or in the account’s company currency when the deal has none, dated the deal’s close date.
  • Each deal is credited once. Its transaction id is hubspot: followed by the deal id.
  • A deal that was already won before you connected, and has not changed since, is not read.

Lost deals

  • An open or lost deal that was never credited is left alone.
  • A credited deal that leaves its won stage, back to an open stage or to a lost one, has its commission reversed, as a refund of the whole amount. A commission already paid out is taken back from the partner’s next payout.

When the connection breaks

When HubSpot refuses the key, because it was deleted or lost a scope, Affiligato stops using it. The HubSpot panel says HubSpot refused this service key. Connect again with a new service key. and shows the form again.

  • Contacts that were waiting to be sent are kept, and go out once you connect again.
  • People referred while the connection was broken are not sent.
  • Affiligato keeps its place in the deals, so deals that changed while the connection was broken are read after you connect again.

When HubSpot answers that there are too many requests, Affiligato stops and continues from the same place on its next run.

Disconnect

Disconnect on the HubSpot panel forgets the key. The affiligato_partner property and the contacts stay in HubSpot. Delete the service key in HubSpot too.