How to read the JSON from the Presence API responce of Daily.co

I have a video call application, and I use the service of Daily.co. To keep track of which users are online, I am writing the current date/time to the user’s profile every 30 seconds. Then I have a background workflow that checks if users have been offline for longer than 5 minutes. If that is the case, this workflow adjusts the status of the user to “offline”.

I like to bring the range of 5 minutes down.

Unfortunately, keeping track of a user’s presence every 30 seconds is not a reliable method. This is because browsers allocate less memory to tabs that are not active. This happens when a user works with a coworker and uses other browser tabs to do their work. As a result, in these cases, I sometimes receive a browser signal only every 10 minutes, and my application will set the user status to offline.

Now, Daily.co has an API call that allows you to retrieve data on who is online and in which room they are. However, I am stuck in the use of this API call. The structure of the JSON response is set up in such a way that the API connector does not pick it up properly. To illustrate, I have included a piece of JSON with two video calls. In one room there are two users and in the other only one.

{
       "room-id-1":[
          {
             "room":"room-id-1",
             "id":"6435dd71-352f-4deb-bcdf-21901ca7733a",
             "userId":"3b5544ee-e6ac-4c82-8a95-0243509d4184",
             "userName":"John",
             "joinTime":"2023-01-14T15:14:03.000Z",
             "duration":226
          },
          {
             "room":"room-id-1",
             "id":"4cbab034-fb37-41bd-8678-4e0ebd49a748",
             "userId":"3b5544ee-e6ac-4c82-8a95-0243509d4183",
             "userName":"Mike",
             "joinTime":"2023-01-14T15:12:42.000Z",
             "duration":307
          }
       ],
       "room-id-2":[
          {
             "room":"b16oSo3QSyI2OUw8erSn",
             "id":"3b5544ee-e6ac-4c82-8a95-0243509d4185",
             "userId":"3b5544ee-e6ac-4c82-8a95-0243509d4182",
             "userName":"Bart",
             "joinTime":"2023-01-14T15:16:14.000Z",
             "duration":95
          }
       ]
    }

What you get when you feed this JSON to the API connector is illustrated in de image below. You see that Bubble saves the names of the video rooms in the API’s data model. In this way, I can’t do anything with it.

What are my options from this point to implement this IPA call in my application successfully?

1 Like

Is it not always room-1 and room-2

Personally I’d write some JavaScript to adjust this from a straight Json object to an array of Json objects. That’s basically what needs to happen here

1 Like

Hi @mike_verbruggen it’s really hard to do without some javascript. The Daily plugin has a presence action that you can copy if you wanted to create a custom action (or you could use the plugin). It’s the Daily - get presence. Happy to help with implementation!

Lola

1 Like

Hi Lola, I will look at the Daily Plugin for inspiration.

And I’m interested in talking about how you could help with my project.

1 Like

Awesome, happy to see if I can help. Feel free to send over a PM!

Lola