HubSpot Integration

HubSpot Integration

Connect HubSpot Service Hub to TR-AI using a Private App token.

Note:TR-AI uses a HubSpot Private App Access Token (starts with pat-). Replies are posted as Note engagements associated with the ticket — HubSpot Service Hub does not have a direct "reply" API on tickets.

Credentials required

FieldWhere to find it
Access TokenHubSpot → Settings → Integrations → Private Apps → Create a private app → Auth tab → Access Token
Pipeline ID (optional)HubSpot → Service → Tickets → Pipeline settings → Pipeline ID in the URL

Step 1 — Create a Private App

  1. 1
    Open Private Apps
    Go to HubSpot → Settings → Integrations → Private Apps → Create a private app.
  2. 2
    Set required scopes
    Under the Scopes tab, enable:
    • crm.objects.tickets.read
    • crm.objects.tickets.write
    • crm.objects.notes.read
    • crm.objects.notes.write
    • crm.schemas.tickets.read
  3. 3
    Copy the Access Token
    After creating the app, go to the Auth tab and copy the Access Token.

Step 2 — Enter credentials in TR-AI

In your TR-AI Dashboard, open the HubSpot card. Paste your Access Token. Optionally enter a Pipeline ID to target a specific service pipeline. Click Save. TR-AI verifies by calling GET /account-info/v3/details.

Step 3 — Create a HubSpot Workflow webhook

  1. 1
    Create a Ticket-based workflow
    Go to HubSpot → Automation → Workflows → Create workflow → Ticket-based.
  2. 2
    Set the trigger
    Ticket is created (for new tickets). For follow-ups, add a second workflow triggered on Ticket property updated when a reply is received.
  3. 3
    Add a webhook action
    Add action: Send a webhook. Set Method = POST and URL:
Webhook URL
https://ticketresolve.ai/api/integrations/hubspot/webhook/{your-trial-id}
  1. 1
    Set the request body
    Select Custom request body and paste:
Webhook payload
{
  "ticket_id":     "{{ticket.hs_object_id}}",
  "subject":       "{{ticket.subject}}",
  "description":   "{{ticket.content}}",
  "contact_name":  "{{ticket.associations.contact.firstname}} {{ticket.associations.contact.lastname}}",
  "contact_email": "{{ticket.associations.contact.email}}",
  "event_type":    "ticket.creation"
}

How TR-AI replies to HubSpot tickets

HubSpot Service Hub does not have a "reply" endpoint on tickets. TR-AI creates a Note engagement associated with the ticket, which appears in the ticket timeline. The Note body contains the AI-generated resolution.

The process:

  • POST /crm/v3/objects/notes — creates the Note with the reply text.
  • PUT /crm/v3/objects/notes/{noteId}/associations/tickets/{ticketId}/note_to_ticket — associates the Note with the ticket.

Pipeline stage management

TR-AI looks up pipeline stages at runtime via GET /crm/v3/pipelines/tickets and caches them for 10 minutes. Stage IDs vary per HubSpot portal — TR-AI never hard-codes them.

ActionStage used
Auto-resolvedStage with metadata.isClosed=true, or label containing "Closed"
TriageStage with label containing "Waiting on Us" — falls back to "Waiting on Contact"

Triage behaviour

When TR-AI cannot auto-resolve a ticket, it:

  • Posts a Note engagement with the acknowledgement text.
  • Moves the ticket to the Waiting on Us stage (or Waiting on Contact as fallback).
  • Sends a Slack notification if configured.

Follow-up detection

TR-AI treats a webhook as a follow-up when event_type contains reply, update, or propertychange. For follow-ups, latest_reply is used as the query body instead of description.