Edits history of script submission #23335 for ' Find Meeting Times (outlook)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Find Meeting Times
     * Suggest meeting times that work for the connected account and the given attendees, within a window of local times in `time_zone`. Work or school accounts only. `extra` takes any other findMeetingTimes property (e.g. `minimumAttendeePercentage`, `isOrganizerOptional`). Requires Calendars.Read.Shared, which is not a connection default: tick it when connecting.
     */
    export async function main(
      auth: RT.Outlook,
      attendees: string[],
      start: string,
      end: string,
      time_zone: string = "UTC",
      duration_minutes: number = 30,
      max_candidates: number | undefined,
      extra: { [key: string]: any } | undefined
    ) {
      const body: { [key: string]: any } = {
        ...(extra ?? {}),
        attendees: attendees.map((address) => ({
          type: "required",
          emailAddress: { address },
        })),
        timeConstraint: {
          timeSlots: [
            {
              start: { dateTime: start, timeZone: time_zone },
              end: { dateTime: end, timeZone: time_zone },
            },
          ],
        },
        meetingDuration: `PT${duration_minutes}M`,
      }
      if (max_candidates != null) body.maxCandidates = max_candidates
    
      const response = await fetch(
        "https://graph.microsoft.com/v1.0/me/findMeetingTimes",
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/json",
            Accept: "application/json",
            Prefer: `outlook.timezone="${time_zone}"`,
          },
          body: JSON.stringify(body),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago

  • bunnative
    //native
    
    /**
     * Find Meeting Times
     * Suggest meeting times that work for the connected account and the given attendees, within a window of local times in `time_zone`. Work or school accounts only. `extra` takes any other findMeetingTimes property (e.g. `minimumAttendeePercentage`, `isOrganizerOptional`). Requires Calendars.Read.Shared on the connection.
     */
    export async function main(
      auth: RT.Outlook,
      attendees: string[],
      start: string,
      end: string,
      time_zone: string = "UTC",
      duration_minutes: number = 30,
      max_candidates: number | undefined,
      extra: { [key: string]: any } | undefined
    ) {
      const body: { [key: string]: any } = {
        ...(extra ?? {}),
        attendees: attendees.map((address) => ({
          type: "required",
          emailAddress: { address },
        })),
        timeConstraint: {
          timeSlots: [
            {
              start: { dateTime: start, timeZone: time_zone },
              end: { dateTime: end, timeZone: time_zone },
            },
          ],
        },
        meetingDuration: `PT${duration_minutes}M`,
      }
      if (max_candidates != null) body.maxCandidates = max_candidates
    
      const response = await fetch(
        "https://graph.microsoft.com/v1.0/me/findMeetingTimes",
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/json",
            Accept: "application/json",
            Prefer: `outlook.timezone="${time_zone}"`,
          },
          body: JSON.stringify(body),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 6 hours ago