HubSpot Lead Enrichment with Perplexity AI & Val Town
This val automates the process of generating an AI-powered research report for new HubSpot leads and attaching a link to that report back onto the HubSpot contact record.
Fill these in under Environment variables on the left sidebar:
HUBSPOT_API_KEY
PERPLEXITY_API_KEY
Setup Instructions
1. HubSpot Configuration
a. Create a Private App
In your HubSpot account, navigate to Settings (gear icon on the top) > Integrations > Private Apps.
Click "Create private app".
Basic Info:
Name: Give your app a descriptive name (e.g., "Val Town Lead Research").
Description: (Optional) Briefly describe its purpose.
Scopes: Go to the "Scopes" tab. You need to grant the following permissions:
crm.objects.contacts.read - To read newly created contact details.
crm.objects.contacts.write - To update the contact with the report link.
(Recommended for robustness)crm.schemas.contacts.read
(Recommended for robustness)crm.schemas.contacts.write
Click "Create app".
After creation, HubSpot will show you an Access Token. Copy this token securely. This will be your HUBSPOT_API_KEY in Val Town.
b. Create a Custom Contact Property
In HubSpot, navigate to Settings (gear icon) > Properties (under "Data Management").
Ensure "Contacts" is selected as the object.
Click "Create property".
Property Details:
Object type: Contact
Group: Contact information (or any group you prefer)
Property label:Research Report URL (or similar)
Click "Next".
Field type: Select "Single-line text".
Click "Create".
Note down the Internal name of this property (e.g., research_report_url). The Val Town script uses research_report_url by default. If yours is different, you'll need to update the script.