Metadata (upcoming)

Available in version 1.1.72 (not yet live).

Read TaskBot and agent details.

API zw.getTaskbotInfo(), zw.getAgentInfo()

const taskbotInfo = await zw.getTaskbotInfo();
await zw.log("variables", taskbotInfo.variables);

const agent = zw.getAgentInfo();
await zw.log("agent version", agent.version);

At a Glance

  • await zw.getTaskbotInfo()

    {
      id: number,
      runType: "immediate" | "scheduled" | "webhook",
      currentRunResult: "success" | "warning" | "error" | "manually_stopped",
      variables: { ref_id: number, variableNames: string[] },
      tables: Array<{
        ref_id: number,
        type: "G_SHEETS" | "ZW_NATIVE",
        columnNames: string[]
      }>,
      webhookURL: string | null,
    }
  • zw.getAgentInfo(){ version: string } (for example, { version: "1.1.72" })

Examples

// Branch behavior by run type

const info = await zw.getTaskbotInfo();
if (info.runType === "scheduled") {
  await zw.log("Running in scheduled mode");
}
// Get tables by type

const info = await zw.getTaskbotInfo();
const gSheets = info.tables.filter(t => t.type === "G_SHEETS");
await zw.log("Google Sheets tables", gSheets);
// @zw-run-locally

import axios from "axios";

// Add TaskBot webhook to global state
const info = await zw.getTaskbotInfo();
const webhook = info.webhook;
if (webhook) {
  (zw.globalState.access().webhooksToTrigger ||= []).push(webhook);
}

// In another TaskBot, access global state and trigger webhooks
const webhooks = zw.globalState.access().webhooksToTrigger || [];
for (const url of webhooks) {
  await axios.post(url);
}

Notes

  • Names, not values. For tables and variables, metadata returns names (variable names and column names). To read values, use zw.getRef().

  • Async behavior. zw.getTaskbotInfo() is async in the browser and sync locally. zw.getAgentInfo() is sync everywhere.

Last updated

Was this helpful?