Edits history of script submission #1081 for ' New Recording (twilio)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    import { Twilio } from "twilio";
    import { getState, setState } from "windmill-client@1";
    
    type Twilio = {
      accountSid: string;
      token: string;
    };
    
    export async function main(auth: Twilio) {
      const client = new Twilio(auth.accountSid, auth.token);
    
      const lastCheckedTime: number | null = await getState();
    
      const recordings = await client.recordings.list();
    
      const newRecordings = lastCheckedTime
        ? recordings.filter(
            (recording) => recording.dateCreated.getTime() > lastCheckedTime
          )
        : recordings;
    
      if (newRecordings.length > 0) {
        await setState(newRecordings[0].dateCreated.getTime());
      }
    
      return newRecordings;
    }
    

    Submitted by hugo697 399 days ago

  • bun
    import { Twilio } from "twilio";
    import { getState, setState } from "windmill-client@1";
    
    type Twilio = {
      accountSid: string;
      token: string;
    };
    
    export async function main(auth: Twilio) {
      const client = new Twilio(auth.accountSid, auth.token);
    
      const lastCheckedTime: number | null = await getState();
    
      const recordings = await client.recordings.list();
    
      const newRecordings = lastCheckedTime
        ? recordings.filter(
            (recording) => recording.dateCreated.getTime() > lastCheckedTime
          )
        : recordings;
    
      if (newRecordings.length > 0) {
        await setState(newRecordings[0].dateCreated.getTime());
      }
    
      return newRecordings;
    }
    

    Submitted by hugo697 973 days ago