Skip to main content

Webhook Triggers

Connect HubSpot workflows to Agent.AI using webhooks - automatically trigger Agent.AI workflows when things happen in HubSpot. Common uses:
  • Run enrichment when contact is created
  • Start onboarding when deal closes
  • Update records when properties change
  • Trigger analysis when stage changes
  • Send notifications on specific events

What This Does (The Simple Version)

Think of webhooks as a doorbell. When something happens in HubSpot (contact created, deal closed, etc.), HubSpot “rings the doorbell” by sending a webhook to Agent.AI. This starts your Agent.AI workflow automatically. Real-world example: When a new contact is added to HubSpot, you want to automatically enrich them with company data. Set up a HubSpot workflow that sends a webhook to Agent.AI whenever “Contact Created” happens. Agent.AI receives the webhook and runs your enrichment workflow.

How It Works

Two parts:
  1. HubSpot Workflow - Watches for events (contact created, deal updated, etc.) and sends webhook
  2. Agent.AI Workflow - Receives webhook and runs your automation
Flow:
  1. Event happens in HubSpot (e.g., deal closes)
  2. HubSpot workflow triggers
  3. HubSpot sends webhook (HTTP POST) to Agent.AI
  4. Agent.AI workflow starts with data from webhook
  5. Agent.AI runs your actions
  6. Updates go back to HubSpot

Setting It Up

Part 1: Create Agent.AI Workflow with Webhook Trigger

Step 1: Start new workflow in Agent.AI
  1. Click “Create Workflow”
  2. Add trigger: Webhook
  3. Copy the webhook URL (looks like: https://agent.ai/webhook/abc123)
You’ll paste this URL into HubSpot in Part 2. Step 2: Note which variables you need Your Agent.AI workflow will receive data from HubSpot. Decide what you need: For contact workflows:
  • contact_id - Contact’s HubSpot ID (required)
  • contact_email - Email address
  • contact_company - Company name
  • Any other contact properties
For deal workflows:
  • deal_id - Deal’s HubSpot ID (required)
  • deal_name - Deal name
  • deal_amount - Deal amount
  • deal_stage - Current stage
  • Any other deal properties
For company workflows:
  • company_id - Company’s HubSpot ID (required)
  • company_name - Company name
  • company_domain - Domain
  • Any other company properties
Always include:
  • _hubspot_portal - Identifies which HubSpot account sent it

Part 2: Create HubSpot Workflow that Sends Webhook

Step 1: Go to HubSpot Automation
  1. In HubSpot, go to AutomationWorkflows
  2. Click Create workflow
  3. Choose From scratch
Step 2: Set trigger Choose what event should start this: Common triggers:
  • Contact-based: “Contact is created”, “Contact property changed”
  • Deal-based: “Deal stage changed”, “Deal is created”
  • Company-based: “Company is created”, “Company property changed”
Example: “Deal stage is Closed Won” (triggers when deal closes) Step 3: Add webhook action
  1. Click + to add action
  2. Search for “webhook”
  3. Select Send a webhook
  4. Click Add action
Step 4: Configure webhook Webhook URL:
  • Paste the Agent.AI webhook URL from Part 1
Method:
  • Select POST
Payload format:
  • Select JSON
Step 5: Build payload Click into the Body field and construct JSON: Template:
{
  "_hubspot_portal": "{{portal.id}}",
  "object_id": "{{object.hs_object_id}}",
  "property_name": "{{object.property_name}}"
}
Example - Contact created webhook:
{
  "_hubspot_portal": "{{portal.id}}",
  "contact_id": "{{contact.hs_object_id}}",
  "contact_email": "{{contact.email}}",
  "contact_company": "{{contact.company}}",
  "contact_name": "{{contact.firstname}} {{contact.lastname}}"
}
Example - Deal closed webhook:
{
  "_hubspot_portal": "{{portal.id}}",
  "deal_id": "{{deal.hs_object_id}}",
  "deal_name": "{{deal.dealname}}",
  "deal_amount": "{{deal.amount}}",
  "close_date": "{{deal.closedate}}",
  "deal_stage": "{{deal.dealstage}}"
}
Example - Property changed webhook:
{
  "_hubspot_portal": "{{portal.id}}",
  "contact_id": "{{contact.hs_object_id}}",
  "lifecycle_stage": "{{contact.lifecyclestage}}",
  "old_value": "{{contact.lifecyclestage.original}}",
  "new_value": "{{contact.lifecyclestage.updated}}"
}
Step 6: Save and activate
  1. Click Save
  2. Toggle to On (activate workflow)
  3. Test by creating a test record that matches trigger

Common Webhook Patterns

Contact Enrichment on Creation

HubSpot trigger: Contact is created Webhook payload:
{
  "_hubspot_portal": "{{portal.id}}",
  "contact_id": "{{contact.hs_object_id}}",
  "contact_email": "{{contact.email}}",
  "contact_company": "{{contact.company}}"
}
Agent.AI actions:
  1. Lookup contact details
  2. Web search for company
  3. AI enrichment analysis
  4. Update contact with insights

Deal Onboarding on Close

HubSpot trigger: Deal stage is “Closed Won” Webhook payload:
{
  "_hubspot_portal": "{{portal.id}}",
  "deal_id": "{{deal.hs_object_id}}",
  "deal_name": "{{deal.dealname}}",
  "deal_amount": "{{deal.amount}}",
  "close_date": "{{deal.closedate}}"
}
Agent.AI actions:
  1. Lookup deal + associations
  2. Get engagement history
  3. AI onboarding plan
  4. Create timeline events

Lead Scoring on Update

HubSpot trigger: Contact property “Job Title” is known Webhook payload:
{
  "_hubspot_portal": "{{portal.id}}",
  "contact_id": "{{contact.hs_object_id}}",
  "job_title": "{{contact.jobtitle}}",
  "company": "{{contact.company}}",
  "email": "{{contact.email}}"
}
Agent.AI actions:
  1. Lookup full contact
  2. Calculate lead score
  3. Update contact with score
  4. If high score → notify sales

Testing Your Webhook

Test in Agent.AI First

Before connecting to HubSpot:
  1. Go to your Agent.AI workflow
  2. Click Test or Run
  3. Manually enter test webhook data
  4. Verify workflow runs correctly
Example test data:
{
  "_hubspot_portal": "12345678",
  "contact_id": "123456",
  "contact_email": "[email protected]",
  "contact_company": "Test Company"
}

Test HubSpot Workflow

After connecting:
  1. In HubSpot workflow, click Test
  2. Select a test record (contact, deal, etc.)
  3. Click Test action
  4. HubSpot sends webhook to Agent.AI
  5. Check Agent.AI execution log

Check Execution Log

In Agent.AI:
  1. Go to workflow
  2. View Executions or History
  3. See webhook data received
  4. Check if all variables arrived
  5. Debug any issues

Troubleshooting

Webhook Not Triggering

Agent.AI workflow doesn’t run Possible causes:
  1. HubSpot workflow not activated
  2. Test record doesn’t match trigger criteria
  3. Webhook URL incorrect
How to fix:
  1. Check HubSpot workflow is On
  2. Verify trigger conditions match test record
  3. Copy/paste webhook URL again from Agent.AI
  4. Check HubSpot workflow history for errors

Variables Missing in Agent.AI

Webhook arrives but variables are empty Possible causes:
  1. Property not populated in HubSpot
  2. Wrong property name in payload
  3. Syntax error in JSON
How to fix:
  1. Check HubSpot record has those properties filled
  2. Verify exact property names (case-sensitive)
  3. Test JSON payload in HubSpot workflow test mode
  4. View Agent.AI execution log to see what was received

Wrong Portal ID

Workflow runs but can’t access HubSpot Possible causes:
  1. _hubspot_portal missing from payload
  2. Not connected to correct HubSpot account
How to fix:
  1. Always include "_hubspot_portal": "{{portal.id}}" in payload
  2. Verify correct HubSpot account connected in Agent.AI

HubSpot Shows Webhook Error

HubSpot workflow shows webhook action failed Possible causes:
  1. Agent.AI webhook URL changed
  2. Agent.AI workflow deleted
  3. Network issue
How to fix:
  1. Get fresh webhook URL from Agent.AI
  2. Update in HubSpot workflow
  3. Test again
  4. Check Agent.AI workflow still exists

Tips & Best Practices

✅ Do:
  • Always include _hubspot_portal in payload
  • Always include object ID (contact_id, deal_id, etc.)
  • Test with sample records first
  • Use descriptive variable names
  • Keep payload simple - only essential properties
  • Check execution logs after testing
  • Use HubSpot workflow test mode
❌ Don’t:
  • Send entire object (only needed properties)
  • Forget to activate HubSpot workflow
  • Use webhooks for batch operations (use scheduled instead)
  • Assume properties are always filled
  • Include sensitive data in webhook
  • Create circular webhooks (Agent.AI → HubSpot → Agent.AI)
Performance:
  • Webhooks trigger instantly (under 1 second)
  • Agent.AI workflow starts immediately
  • Total time depends on actions inside workflow
  • Typical enrichment: 5-15 seconds end-to-end
Payload tips:
  • Use {{object.hs_object_id}} for object ID
  • Use {{portal.id}} for portal ID
  • Property names match HubSpot internal names
  • Use {{property.original}} for old value
  • Use {{property.updated}} for new value

Workflow examples using webhooks: Related guides: Actions used after webhooks:
Last Updated: 2025-10-01