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 transcriptions = await client.transcriptions.list({
limit: 1000,
});
const newTranscriptions = lastCheckedTime
? transcriptions.filter(
(transcription) => transcription.dateCreated.getTime() > lastCheckedTime
)
: transcriptions;
if (newTranscriptions.length > 0) {
await setState(newTranscriptions[0].dateCreated.getTime());
}
return newTranscriptions;
}
Submitted by hugo697 439 days ago