# HubSpot: save WhatsApp customers as contacts

> Connect HubSpot to Avox so an automation can add a WhatsApp customer to HubSpot as a contact, or update the one that is already there. Steps, limits and what happens if HubSpot fails.

Source: https://docs.theavoxai.com/connections/apps/hubspot

Connect HubSpot and an automation can save the people who message you, with what they told you in a
chat or a Flow, as contacts in your HubSpot account. Your team then works from HubSpot as usual. You
can also look at those contacts, and search the ones already in HubSpot, from inside Avox.

## What Avox can and cannot do with HubSpot

- **Can:** add a contact, or update the one that is already there. With an email, Avox updates the
  contact with the same email, or creates it. Without an email, it looks for a contact with the same
  phone number first, and creates one if there is none.
- **Can:** fill email, phone, first name, last name and company.
- **Can:** list and search your HubSpot contacts on the **Contacts** page, and open one in HubSpot.
- **Cannot:** work with deals, companies or tickets. They stay in HubSpot.
- **Cannot:** save the note. A step has a **Note** box, but HubSpot ignores it, so it never reaches
  the contact.
- **Cannot:** change or delete contacts from the Contacts page. It only reads. Change them in HubSpot.
- **One direction only:** Avox writes to HubSpot. Nothing you change in HubSpot starts an automation
  in Avox.

Fields you leave empty are not sent, so they never blank out what HubSpot already holds.

## What you need before you start

- A HubSpot account, and a HubSpot user who is allowed to install apps in it. If HubSpot refuses the
  install, ask your HubSpot admin.
- A plan on your Switchboard. The plan sets how many apps you can connect at once
  ([AVX-3683](https://docs.theavoxai.com/error-codes/avx-3683), [AVX-3706](https://docs.theavoxai.com/error-codes/avx-3706)).
- The permission **Manage connected apps** in Avox. Admins have it, and an Admin can give it to a
  Manager. Without it the **Connect** button is greyed out ([AVX-3707](https://docs.theavoxai.com/error-codes/avx-3707)).

## Connect HubSpot

**1. Open HubSpot in Apps**

In the dashboard open **Apps** in the sidebar, pick **HubSpot** and click **Connect**.

**2. Read what Avox will do**

The first screen, **What Avox can do**, lists the abilities. Click **Continue**.

**3. Sign in at HubSpot**

Click **Continue to HubSpot**. HubSpot's own page opens. Choose the HubSpot account and allow what
Avox asks for: finding contacts, and adding and changing contacts. Avox never sees your password.

**4. Come back to Avox**

You return to Avox with **HubSpot is connected**. Click **Open HubSpot in Avox** or **See contacts**.

If the button says **Coming soon**, Avox has not switched HubSpot on yet ([AVX-3682](https://docs.theavoxai.com/error-codes/avx-3682)).
Nothing is wrong on your side. Leave every permission ticked, or Avox shows which ones are missing
([AVX-3690](https://docs.theavoxai.com/error-codes/avx-3690)). If the sign-in ends with an error, see
[Apps troubleshooting](https://docs.theavoxai.com/connections/apps/troubleshooting).

## What you see in Avox afterwards

Open **Apps**, then **HubSpot**. The menu has **Overview**, **Contacts** and **Activity**.

- **Overview** shows the status, the HubSpot account, who connected it and when, when it last worked
  and the last problem with its code. Click **Test connection** for a check in a second. **Reconnect**
  and **Disconnect** are here too.
- **Contacts** has two lists: **Sent by Avox** (the contacts Avox added or updated, marked **Has a
  chat** when it knows the chat they came from) and **In HubSpot** (your HubSpot contacts,
  searchable, with **Load more**). Open one for its details, **Open chat** and **Open in HubSpot**.
  Lists hide most personal details, and a contact's own page shows them.
- **Activity** has **Usage** (calls per day over 7, 30 or 90 days) and the **Log**: every call Avox
  made, with the time, action, source, result and code. Filter by result, action or source.

The status is one of **Connected**, **Needs reconnecting** or **Having trouble**. Avox renews
HubSpot's access by itself before it runs out.

## Using HubSpot in Avox

Flows do not call HubSpot directly. To save a Flow's answers, make an automation that starts with
**Flow submitted**. HubSpot is used by one step, and it is free (no credits).

Add a **Use a connected app** step, set **What to do** to **Save to your CRM** under **CRM**, and
pick **HubSpot** in **With**. Fill any of: **Email**, **Phone**, **First name**, **Last name**,
**Company** and **Note** with fixed text or values like `{{flow.email}}`. Email or phone is needed
([AVX-3705](https://docs.theavoxai.com/error-codes/avx-3705)). The email is stored in lower case. A phone is digits, spaces,
brackets or dashes, optionally starting with +, 6 to 24 characters.

Automations can use only three details of the person in the chat: `{{contact.name}}`,
`{{contact.first_name}}` and `{{contact.phone_last4}}` (the last 4 digits), plus your own custom
contact fields. The full phone number is not offered as a value, so collect the email or phone in a
Flow, or read it from a table row such as `{{row.phone}}`.

Later steps can use `{{crm.id}}` (the HubSpot contact id) and `{{crm.created}}` (yes or no).

**Worked example (made up for illustration).** A Flow asks for first name, last name, email and
company. An automation starts with **Flow submitted** for that Flow and has one **Use a connected
app** step: **Save to your CRM** with **HubSpot**, **Email** `{{flow.email}}`, **First name**
`{{flow.first_name}}`, **Last name** `{{flow.last_name}}` and **Company** `{{flow.company}}`. Use the
names of your own Flow's fields. Set **If it can't be done** to **Carry on with the next step**, then
add a text that thanks the customer. A returning customer with the same email is updated, not added
twice.

There is no premade automation for HubSpot. Build this one in the [builder](https://docs.theavoxai.com/automation/tables).

## Limits

- Each Switchboard can make 120 calls a minute to HubSpot. Past that, calls are refused for the rest
  of the minute ([AVX-3695](https://docs.theavoxai.com/error-codes/avx-3695)).
- Each try gives up after 10 seconds, and a step waits 30 seconds at most.
- First and last name: 80 characters. Company: 120. Note: 1,000.
- One contact per step. The Contacts page loads 20 at a time.

## When HubSpot fails or says no

HubSpot is someone else's service, so it can be slow, busy or say no. Avox is built so that never
breaks your account.

1. **Retries.** Adding or updating by email, finding by phone, updating, listing and reading are
   tried again, up to two more times after about 0.4 and 1.2 seconds, when HubSpot is unreachable or
   answers 429, 502, 503 or 504. If HubSpot says how long to wait, Avox waits up to 5 seconds. The
   one call with no safe repeat key, creating a new contact when there is no email and no match by
   phone, is not tried again.
2. **The log.** Each call is logged with its tries. Names, emails and phone numbers are masked (a
   company name is shown as typed), and the answer kept is only the contact's HubSpot id.
3. **The status.** If HubSpot stops accepting Avox's access, the status becomes **Needs reconnecting**
   at once ([AVX-3692](https://docs.theavoxai.com/error-codes/avx-3692)). Five failed calls in a row on HubSpot's side make it
   **Having trouble**, and one good call makes it **Connected** again. A detail that is missing or
   not valid does not count against its health.
4. **Your automation.** The step stops the run or carries on, as you chose in **If it can't be done**
   (the default is **Stop the run**). If a run stops, later steps such as a thank-you text do not
   run. While HubSpot **Needs reconnecting**, the step does not call HubSpot and fails with
   [AVX-3596](https://docs.theavoxai.com/error-codes/avx-3596) in the automation's run log. Other failures show
   [AVX-3605](https://docs.theavoxai.com/error-codes/avx-3605).
5. **The pages.** If HubSpot cannot be read, **Contacts** shows what Avox saved, with
   [AVX-3717](https://docs.theavoxai.com/error-codes/avx-3717) and the reason.

**What happens to the person's data.** If the save fails, that contact is not in HubSpot, and Avox
does not try it again later on its own. The chat goes on and the Flow answers stay in your Inbox. To
add the contact, correct the cause and run the automation again, or add it in HubSpot.

Codes you may see: [AVX-3694](https://docs.theavoxai.com/error-codes/avx-3694) HubSpot is not answering,
[AVX-3695](https://docs.theavoxai.com/error-codes/avx-3695) slow down, [AVX-3713](https://docs.theavoxai.com/error-codes/avx-3713) HubSpot refused a
value (open the log entry to read why), [AVX-3705](https://docs.theavoxai.com/error-codes/avx-3705) a detail is missing or not
valid, [AVX-3711](https://docs.theavoxai.com/error-codes/avx-3711) the Switchboard is paused, and
[AVX-3739](https://docs.theavoxai.com/error-codes/avx-3739) staff turned HubSpot off for your account. Each entry in the log
says which one applied.

## Disconnecting

Click **Disconnect** on HubSpot's Overview. Avox shows what uses it, asks HubSpot to drop its
access, and deletes the access it saved. The log and usage stay for your retention period. The
contacts it saved stay in HubSpot. Steps that use HubSpot fail until you connect again. If you see
[AVX-3697](https://docs.theavoxai.com/error-codes/avx-3697), remove Avox in HubSpot's connected apps settings too.

## Common questions

**Why do I have two contacts for one customer?**

Avox matches on email first. Without an email it asks HubSpot for the same phone number as written,
so a number saved differently in HubSpot, for example with spaces or no country code, is not found
and a new contact is made. Pass the email whenever you have it.

**Where did my note go?**

HubSpot ignores it. Only email, phone, first name, last name and company are saved.

**Does a change in HubSpot start an automation?**

No. Avox only writes to HubSpot, and reads it when you open a page.

**Can I connect a second HubSpot account?**

One HubSpot account per Switchboard. Signing in with another account is refused
([AVX-3703](https://docs.theavoxai.com/error-codes/avx-3703)). Disconnect first to switch.

## Related
