This application uses MySQL database to store the events coming from Webhooks. There is a single events table:
create table if not exists events
(
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
event_type VARCHAR(255),
object_id int default null,
event_id bigint default null,
occurred_at bigint default null,
property_name varchar(255) default null,
property_value varchar(255) default null,
created_at datetime default CURRENT_TIMESTAMP
);
Please note that event_id sent by HubSpot needs to be stored as int
Make sure you have Docker Compose installed.
- Copy .env.template to .env
- Paste your HUBSPOT_CLIENT_ID, HUBSPOT_CLIENT_SECRET, HUBSPOT_APPLICATION_ID and HUBSPOT_DEVELOPER_API_KEY
The best way to run this project (with the least configuration), is using docker compose. Change to the webroot and start it
docker-compose up --build
Copy Ngrok url from console. Now you should now be able to navigate to that url and use the application.
If you are using Ngrok free plan and testing the application with large amount of import/deletions of Contacts you are likely to see Ngrok "Too Many Connections" error. This is caused by a large amount of weebhooks events being sent to Ngrok tunnel. To avoid it you can deploy sample applications on your server w/o Ngrok or upgrade to Ngrok Enterprise version
To help improve security, HubSpot webhooks are sent with signature so you can verify that it came from HubSpot. This sample application shows how to do that verification. You can read more about validation in general here: https://developers.hubspot.com/docs/api/webhooks/validating-requests. The source code for validating webhooks is at an usage example.
- Authorize your app with Hubpost OAuth (Press "Authorize" button).
- Subscribe to Hubspot Webhooks (Press "Start" button).
- Create some Hubspot Contacts. You can use this Sample App to do so.
ruby cli.rb -m create -t contact -p '{"email":"brianhalligan@email.com","firstname":"Brian","lastname":"Halligan"}'
- Reload /events page to check recieved updates.