APIs & Integrations

PCarlson
Participant

Best way to get recent open activity for a specific contact

SOLVE

I would really like to be able to show a small list of activities with most recent past logged activities of all types and open tasks due soon to provide a snapshot to a user.

 

I see the following api calls:

  1. associationsApi getAll
  2. Get recent engagements
  3. Get all engagements

I started out with the associationsApi, but it seems to be in a somewhat random order and only returns the id, so requires many additional api calls to get type, due date, etc. Sorting and filtering with that many calls introduces delays and timeouts.

 

Get recent does not let me sort by due date and I still would have to filter to eliminate all other contacts, completed tasks, etc. I would have to eliminate other contacts and the volume for all contacts might require many calls.

 

And get all would require considerable processing to sort and filter to show only open for my contact.

 

Did I miss any api calls that might be useful for my use case?

 

Any comments on which api to use and the best way to approach sorting and filtering?

 

Thanks

 

Phil

0 Upvotes
1 Accepted solution
lynton
Solution
Contributor | Elite Partner
Contributor | Elite Partner

Best way to get recent open activity for a specific contact

SOLVE

I'd suggest using the 'get recent engagements' endpoint, then storing locally to perform any necessary filters. You can keep your local storage up to date by getting recent engagements on a scheduled basis. Once stored locally, you can filter and display them to users however you need. 

 

I might also consider looking at the cross-object report builder to see if a HubSpot dashboard report will serve the majority of what you need, alleviating the extra api work.

View solution in original post

6 Replies 6
PCarlson
Participant

Best way to get recent open activity for a specific contact

SOLVE

I'm not sure who marked this solved, but I see things to resolve and intended it more for discussion.

 

I was able to get recent engagements working, so it does solve my basic requirement and it is mostly a better solution.

 

My main issues are:

  1. date_modified is not the same as due date, specifically for tasks. A task might get scheduled for 2 or more months into the future for followup and not modified. As the due date approaches, it should be included in a list of upcoming tasks. But the recent engagements endpoint only returns engagements modified within 30 days, so that task will not be listed even if due tomorrow.
  2. The recent engagements report is for all contacts, which could (will) be a large volume of information. I'm currently requesting the max 100 engagements and hoping to get several most recent for my target contact. But in a large environment, the 100 most recent can easily not include any for the target contact.
  3. The associations API getAll returns only the id and type, so filter or sort requires a great many api calls to get due date and status.

My use case is listing HubSpot activity in an asynchronous email environment, so I cannot use @lynton's periodic polling or an in-HubSpot dashboard. So I'm really looking for enhancements in future engagement API calls that allow more options for filtering and sorting.

 

For example:

  • Returning the engagement timestamp in the associations API getAll endpoint would let me do my sorting before making additional API calls.
  • Even better would be the ability to specify a list of engagement properties to return using that endpoint.
  • And of course best would be a query type parameter searching and sorting capabilities for engagements.

I'm not pursuing this in the immediate future, so this can be left marked as Solved if you choose. But more information on future features planned for the new engagement API would be welcome.

 

Phil

lynton
Contributor | Elite Partner
Contributor | Elite Partner

Best way to get recent open activity for a specific contact

SOLVE

Phil,

 

Sorry for the misunderstanding. I understand you're looking for improvements to the Engagements API query, and I feel the same way about it. We're expecting new features and improvements to the Engagements API as HubSpot continues upgrades to the API (similar to the v3 CRM API with search and batch operations.)

 

My suggestion is to query all engagements into an internal database. Then after you've loaded all engagements, use the "get recent" engagement to insert/update into your database moving forward. Once all the data is in your system, you can connect this internal data source to your asynchronous email app. You can query by due date or any other engagement fields as needed. It offers the best performance to your users and gives you complete control over how you need to access the data.

 

Let me know if you have any other questions!

PCarlson
Participant

Best way to get recent open activity for a specific contact

SOLVE

Thanks @lynton , I'll play with it this weekend and post what I figure out.

0 Upvotes
lynton
Solution
Contributor | Elite Partner
Contributor | Elite Partner

Best way to get recent open activity for a specific contact

SOLVE

I'd suggest using the 'get recent engagements' endpoint, then storing locally to perform any necessary filters. You can keep your local storage up to date by getting recent engagements on a scheduled basis. Once stored locally, you can filter and display them to users however you need. 

 

I might also consider looking at the cross-object report builder to see if a HubSpot dashboard report will serve the majority of what you need, alleviating the extra api work.

dennisedson
HubSpot Product Team
HubSpot Product Team

Best way to get recent open activity for a specific contact

SOLVE

This @lynton guy is good.  Should open up a dev shop something 🙃

dennisedson
HubSpot Product Team
HubSpot Product Team

Best way to get recent open activity for a specific contact

SOLVE

Hey @PCarlson 

Adding @quentin_lamamy , @zaklein and @lynton to this thread. 

0 Upvotes