Skip to content

webhooksSecretToken not necessary for scripts - should be optional? #4

@nktnet1

Description

@nktnet1

For example, this is the code I'm currently using:

/**
 * ./src/main.tsx
 */

import "dotenv/config";
import { PhoneS2SAuthClient } from "@zoom/rivet/phone";
import * as v from "valibot";

const envSchema = v.object({
  ZOOM_ACCOUNT_ID: v.pipe(v.string(), v.minLength(1)),
  ZOOM_CLIENT_ID: v.pipe(v.string(), v.minLength(1)),
  ZOOM_CLIENT_SECRET: v.pipe(v.string(), v.minLength(1)),
});

const env = v.parse(envSchema, process.env);

const main = async () => {
  const client = new PhoneS2SAuthClient({
    clientId: env.ZOOM_CLIENT_ID,
    clientSecret: env.ZOOM_CLIENT_SECRET,
    accountId: env.ZOOM_ACCOUNT_ID,

    // This could be an optional field instead?
    webhooksSecretToken: "unused",
  });

  try {
    const results = await client.endpoints.callLogs.getUsersCallHistory({
      path: {
        userId: "<REPLACE_WITH_SOME_ZOOM_USER_ID>",
      },
      query: {
        recording_status: "recorded",
        page_size: 1,
      },
    });

    if (!results.data?.call_logs) {
      return null;      
    }

    const res = results.data.call_logs?.map((cl) => {
      return {
        id: cl.id,
        callId: cl.call_id,
        callerName: cl.caller_name,
        recordingType: cl.recording_type,
      };
    });

    console.log(JSON.stringify(res, null, 2));
  } catch (error) {
    console.error("Error:", error);
  }
};

if (import.meta.url === `file://${process.argv[1]}`) {
  void main();
}

It's just a one-off basic script, e.g. run with:

pnpx tsx src/main.tsx

I think having a basic example of this in the docs is also helpful - I couldn't figure out if an actual server was needed to run simple scripts.


That aside, really appreciate that this underrated library exists, with all the typings & convenient features baked in. Thank you.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions