How to get the message count in V3

In API v2.x, we were able to provide view=count by querying the Nylas database directly.  However, in API v3, for Google and Microsoft grants, Nylas no longer stores provider data.  This offers several benefits, e.g. removing the need to synchronize the state we have in the DB with the provider, removing historic sync delay found in v2.x, etc.  But this also means that we are limited by what the provider supports in terms of querying.  Unfortunately, Google/Microsoft don't provide an equivalent to view=count in their respective APIs.
 
To accomplish this in v3, you would need to:

  1. Subscribe to message.created webhooks.
  2. After a grant is connected, page through the grant's existing threads recording the timestamp of each thread (assuming you need to be able to get a count based on a dynamic date range).
  3. Given a message.created webhook, check if the thread is new (e.g. not previously counted), if so, record the timestamp.

 
Depending on the specific details of your use case, the above workflow may need to be adjusted.

 

References:

Using webhooks with Nylas

Updated

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.