# Use Webhook to count participants

**URL:** <https://devforum.zoom.us/t/use-webhook-to-count-participants/57376>\
**Category:** API and Webhooks\
**Created:** [September 13, 2021, 5:48pm UTC](https://devforum.zoom.us/t/use-webhook-to-count-participants/57376 "2021-09-13T17:48:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![1llusion](https://avatars.discourse-cdn.com/v4/letter/1/ee59a6/32.png) [@1llusion](https://devforum.zoom.us/u/1llusion)\
**Post date:** [September 13, 2021, 5:48pm UTC](https://devforum.zoom.us/t/use-webhook-to-count-participants/57376/1 "2021-09-13T17:48:02Z")

</div>

**Description**  
I am trying to track the amount of participant who are at a given time in a meeting. For this I am using a webhook, which receives the participant\_joined and participant\_left events.

On the first event, a participants user\_id is added to a list, on the second event the participant’s user\_id is removed from the list. The number of user\_ids in the list should give the number of people in the meeting at a given time.

**Error**  
I have implemented the scheme as described above and tried it with real-world meetings (up to 200 participants), but fairly quickly the number deviates from the actual number of participants.

As far as I can tell, the webhook method described above lists too many participants.

Is it possible that I am not receiving all events? Would there be a better method to track the number of participants?

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
Webhook

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [September 15, 2021, 4:13pm UTC](https://devforum.zoom.us/t/use-webhook-to-count-participants/57376/2 "2021-09-15T16:13:10Z")

</div>

Hi @1llusion,

The webhooks for participant joins could vary from the unique number of participants for a few reasons. Most notably, if a participant temporarily left and rejoined or was temporarily disconnected, a new webhook would be triggered on each “re-join”.

Additionally, if there is a waiting room enabled, you might be receiving events for participants joining the waiting room and then joining the meeting.

You might also consider querying participants via API:

> **[Get past meeting participants - Meetings - Zoom API - API Reference](https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/pastmeetingparticipants)**
>
> Retrieve information on participants from a past meeting. 
> Scopes: meeting:read:admin meeting:read
> 
> Rate Limit Label: Medium
> Prerequisites:
> 
> Paid accou...

Thanks!  
Will

---

<div class="post-metadata">

**Author:** ![1llusion](https://avatars.discourse-cdn.com/v4/letter/1/ee59a6/32.png) [@1llusion](https://devforum.zoom.us/u/1llusion)\
**Post date:** [September 16, 2021, 11:51am UTC](https://devforum.zoom.us/t/use-webhook-to-count-participants/57376/3 "2021-09-16T11:51:01Z")

</div>

Thanks Will!

Does this mean that for each of these participant\_join events – which could be a re-joins – a new user\_id is assigned AND not all of these have a subsequent participant\_left event?

If so, it means I need to make sure that on participant\_join I don’t add the user to the meeting table, if he is already in there.

So if I modify it as follows, I think it should be fairly robust:

1. On participant\_join check if participant.id is set;  
1.1 if participant.id is set, check our internal meeting table if we already have the same participant.id in there; if so, it is a re-join and we can simply update the existing entry with the new participant.user\_id  
1.2 if participant.id is not set, check internal meeting table if we have a participant with participant.user\_name in there; if so, this is a rejoin and thus we update (as above).

This may still fail to count properly if multiple participants who are not logged into Zoom share the same user\_name, but I think this is fairly unlikely.

Do you think this would work?

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [September 17, 2021, 1:52pm UTC](https://devforum.zoom.us/t/use-webhook-to-count-participants/57376/4 "2021-09-17T13:52:12Z")

</div>

Hi @1llusion,

Good questions, and overall I think this isn’t a bad approach. 🙂

Regarding user\_id, just keep in mind that this will not be unique for each webhook if the user is signed into their Zoom account (in this case, it will always be their own unique user\_id). Otherwise, however, I think your approach will work.

Thanks!  
Will

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [October 17, 2021, 11:52pm UTC](https://devforum.zoom.us/t/use-webhook-to-count-participants/57376/5 "2021-10-17T23:52:37Z")

</div>

Closed on October 17, 2021, 11:52pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
