HubSpot CRM Integration
The Portal integrates with HubSpot CRM for contact management, primarily used by the concierge service to sync landlord and enquiry data.
HubSpotService
File: app/Services/HubSpotService.php
Package: hubspot/api-client (v13.2+)
Configuration
HUBSPOT_API_KEY= # HubSpot access tokenConfigured in config/services.php:
'hubspot' => [
'api_key' => env('HUBSPOT_API_KEY'),
],Constructor
Creates a HubSpot client using Factory::createWithAccessToken(). The API key can be injected or falls back to config. Throws InvalidArgumentException if no key is provided.
Methods
findContactByEmail(string $email): ?string
Searches HubSpot CRM for a contact by email address.
- Uses the HubSpot Search API with a filter on the
emailproperty - Returns the HubSpot contact ID if found,
nullotherwise
updateContact(int|string $contactId, array $properties): array
Updates a contact’s properties in HubSpot.
- Takes a contact ID and an associative array of properties to update
- Returns
['ok' => true, 'contactId' => ..., 'contact' => ..., 'action' => 'updated']
Usage in the Portal
ConciergeService
The primary consumer of HubSpotService is the ConciergeService (app/Services/ConciergeService.php), which manages enquiry distribution and landlord communication. The ConciergeService injects HubSpotService via constructor dependency injection and uses it to:
- Look up landlord contacts in HubSpot when processing enquiries
- Update contact records with enquiry status changes and communication logs
Data Flow
Student submits enquiry
-> ConciergeService processes enquiry
-> HubSpotService.findContactByEmail() looks up landlord
-> HubSpotService.updateContact() syncs status to CRMNotes
- The integration is read/write — the Portal both queries and updates HubSpot records.
- Only the Contacts API is used (no Deals, Companies, or other HubSpot objects).
- The service does not handle contact creation — it only finds and updates existing contacts.