How to get name of person from daily and store it to variable

How to get name of person from daily and store it to variable



  • nienke
    nienke Moderator, Dailynista admin

    In Daily Prebuilt, the user name is displayed on the video tile, but there's no way to get the names of people without making use of the Daily Call Object. What is it you're trying to do exactly? ☺️

  • Lazer
    Lazer Dailynista

    It's also possible to retrieve participant names in embedded Prebuilt. Here's an example (replace YOUR_DAILY_ROOM_URL with your own room URL).

      <script crossorigin src=""></script>
          callFrame = window.DailyIframe.createFrame();
          callFrame.join({ url: 'YOUR_DAILY_ROOM_URL' });
          callFrame.on("participant-joined", (e) => {
            const name = e.participant.user_name;
            console.log("participant name:", name);
            console.log("total participants:", callFrame.participants());

    Above, when another participant joins the call, the local participant will retrieve their name (if they have one set) and set it to the name const. You can also retrieve all participants and their names at any time via the callFrame.participants() method shown there (doesn't have to be in an event handler, can be anywhere that the callFrame variable is in-scope).

    You can also listen to "participant-updated" events to detect when someone changes their name in embedded Prebuilt, like this (based on the callFrame defined in the snippet above):

          callFrame.on("participant-updated", (e) => {
            const name = e.participant.user_name;
            console.log("name of updated participant:", name);

    Note that the "participant-updated" fires on all kinds of updates, not just name changes, so in most cases of this event being emitted the name of the participant above will likely stay the same.

    Hope that helps!