Hi All, I had a query regarding webhooks. I’ve some companies stored in hubspot. Is it possible to call a webhook when I will add notes to a company?
Thanks.
Hi All, I had a query regarding webhooks. I’ve some companies stored in hubspot. Is it possible to call a webhook when I will add notes to a company?
Thanks.
Hi @Akamran,
Currently it is not possible to create webhooks for events happening directly on Engagement objects (Emails, Notes, Tasks, Meetings and Calls).
However an alternative solution to consider is to create a webhook that is triggered anytime the “Last Activity Date” property is updated on the Company. This records the last time a call, chat conversation, LinkedIn message, postal mail, meeting, note, sales email, SMS, or WhatsApp message was logged for a company.
See an example of my webhook in my app:
Anytime I log a note (or any type of engagement for that matter) the webhook is fired and my endpoint receives the payload below:
[
{
"eventId": 2045645441,
"subscriptionId": 2219950,
"portalId": 141307928,
"appId": 1914445,
"occurredAt": 1691763855124,
"subscriptionType": "company.propertyChange",
"attemptNumber": 0,
"objectId": 8240965055,
"propertyName": "notes_last_updated",
"propertyValue": "1691763854789",
"changeSource": "ENGAGEMENTS",
"sourceId": "ObjectPropertyUpdater"
}
]
What you then need to do in order to get the specific engagement information is use the objectId (this is the Company Id) in the payload to retrieve associated engagements. So using the CRM Companies API with the associations parameter we can make a request like this:
GET https://api.hubapi.com/crm/v3/objects/companies/8240965055?associations=note
RESPONSE
{
"id": "8240965055",
"properties": {
"createdate": "2023-08-11T14:23:55.046Z",
"domain": "marvel.com",
"hs_lastmodifieddate": "2023-08-11T14:24:34.991Z",
"hs_object_id": "8240965055",
"name": "Marvel"
},
"createdAt": "2023-08-11T14:23:55.046Z",
"updatedAt": "2023-08-11T14:24:34.991Z",
"archived": false,
"associations": {
"notes": {
"results": [
{
"id": "19456202967",
"type": "company_to_note"
},
{
"id": "19456203473",
"type": "company_to_note"
}
]
}
}
}
Notice the associations object returned in the response. This contains the ID of all engagements (Notes) on the Company. To get specific information we can use the CRM Engagements endpoint like so:
GET https://api.hubapi.com/crm/v3/objects/notes/19456202967?properties=hs_note_body
RESPONSE
"id": "19456202967",
"properties": {
"hs_createdate": "2023-08-11T14:24:14.789Z",
"hs_lastmodifieddate": "2023-08-11T14:24:14.789Z",
"hs_note_body": "<div style=\"\" dir=\"auto\" data-top-level=\"true\"><p style=\"margin:0;\">This is a note</p></div>",
"hs_object_id": "19456202967"
},
"createdAt": "2023-08-11T14:24:14.789Z",
"updatedAt": "2023-08-11T14:24:14.789Z",
"archived": false
}
It’s not perfect but it’s the only way to achieve what you are trying to do. At least until a point in time where HubSpot supports creating webhooks directly for Engagements.
I hope it helps and good luck in your project.
What is the propertyValue in the initial webhook payload above?
“propertyValue”: “1691763854789”,
It appears to be a numer ic identifier. What does that number represent and can a lookup be performed to get a string value of what it represents?
Hey @VBossio,
It’s a UNIX timestamp (1691763854789) and represents the date (Fri Aug 11 2023) the note was last updated. You’d need to convert that in your code to get a readable date.
Thank you, was able to figure that out actually.
That’s kind of odd though, wouldn’t the NoteId (or EngagementId) what was changed be more useful?
Then you could get the last updated date/time from the Note/Engagement.
Not having a webhook for Note changes is a huge issue.
How do you suggest handling bi-directional Notes updates between Hubspot and another system?
Hey @VBossio,
Absolutely, I agree that lack of webhook support for Engagements is an issue. I don’t work at HubSpot so unfortunatley have no visibility as to if and when they plan to support this.
Until they do the only real workarounds are similar to the one in this thread, whereby we use the “Last Activity Date” to detect when an Engagement was updated on a company or any CRM record and then retrieve the associated Engagements for that object.
Thanks @coldrickjack,
But in fact the “Last Activity Date” property is NOT updated on the Company when we MODIFY a Note attached to the Company (ONLY updated when first created).
I think…
Hey @brusky07,
Yes, apologies, there is quite a lot of back and forth in the thread but I recall that we spoke about this so I would defer back to my original answer on that here. In short:
@coldrickjack , understood, many thanks for your confirmation.
I have found this endpoint which can be used to return all engagements with a last modified date “since” a value that you can provide as a parameter.
https://legacydocs.hubspot.com/docs/methods/engagements/get-recent-engagements
The “since” value has to be provided in UNIX timestamp format but it appears to work. My only concern is that this specific endpoint is only available with API v1 and that it may be deprecated at some point.
Thank you, I understand it’s difficult to project what Hubspot will do since you are no longer working there.
The workaround would be fine, except I tested as follows and it doesn’t look like “updates” to Engagements (changing a Note for example) change anything in the Company object:
1. Called the get company by Id API endpoint with all properties and saved the response JSON.
2. Changed a Note that is associated with the company.
3. Called the get company by Id API endpoint again with all properties and saved the response JSON
4. The JSON saved in Steps 1 and 3 was identical.
It appears that only adding new Engagements updates the company Last Activity Date.
Hello @coldrickjack,
I’m not able to find the event which you subscribe for notes.
Can you please guide me from where I can get the notes_last_updated event in webHook?
notes_last_updated it is available while creating a WorkFlow.
Let me correct If I’m wrong.
Thanks in advance.
same man
let me know if you find something
Hey, @mharis7 @JPrajapati3
I tested this in my portal and was able to create the webhook. You may need to manually paste the value into the webhook editor.
Additionally, you can search for this property using the Properties API. Example:
Request
curl --request GET \
--url 'https://api.hubapi.com/crm/v3/properties/company/notes_last_updated?archived=false' \
--header 'authorization: Bearer YOUR_ACCESS_TOKEN'
Response
HTTP 200
{
"updatedAt": "2023-06-26T20:53:54.382Z",
"createdAt": "2020-06-30T15:57:37.548Z",
"name": "notes_last_updated",
"label": "Last Activity Date",
"type": "datetime",
"fieldType": "date",
"description": "The last time a call, chat conversation, LinkedIn message, postal mail, meeting, note, sales email, SMS, or WhatsApp message was logged for a company. This is set automatically by HubSpot based on user actions in the company record.",
"groupName": "company_activity",
"options": [],
"displayOrder": 6,
"calculated": false,
"externalOptions": false,
"hasUniqueValue": false,
"hidden": false,
"hubspotDefined": true,
"modificationMetadata": {
"archivable": true,
"readOnlyDefinition": true,
"readOnlyValue": true
},
"formField": false,
"dataSensitivity": "non_sensitive"
}
Have fun building! — Jaycee
Thank you for your reply.
Yes, When we just paste the notes_last_updated value in the property change event then we can subscribe the event.
Thank you so much @Jaycee_Lewis
i dont have notes_last_updated option in company i have this inside contact @coldrickjack
Many thanks for this.
But it seems that the “Last Activity Date” property is NOT updated on the Company where we MODIFY a Note attached to the Company (ONLY updated when first created).
Or is there another way ?
Many thanks
Hey @bru, unfortunatley not I’m afraid.
The original use was to support triggering a webhook when a note was created, whilst we can’t directly subscribe to those events on the engagement object itself we can use the “Last Activity Date” as mentioned. It’s a company property that represents the time a note was last logged (added) to the record.
There isn’t a company property that stores the last time an update was made to a given note. I’ve also tested to see if at the very least “hs_lastmodifieddate” would update but from my testing it does not.
The only option at present (that I can see) is to poll for changes periodically using the Engagments API. The ideal of course would be to configure a webhook to detect updates on the engagement itself but it’s not supported by HubSpot at the moment and I’m not sure if and when HubSpot plans to support it either.
Many thanks ! In fact I had reached the same conclusion, but then I’m happy to have your confirmation !
Many thanks for your help !