@twilio/flex-sdk
    Preparing search index...

    Class SetWorkerActivity

    Sets an activity for a worker.

    The unique identifier (SID) of the worker to set the activity for.

    The unique identifier (SID) of the activity to be set for the worker.

    Optional configuration parameters for customizing the activity setting process.

    A promise that resolves when the activity is successfully set for the worker.

    import { createClient, SetWorkerActivity } from "@twilio/flex-sdk";

    async function setWorkerActivity() {
    const client = await createClient("SDK_TOKEN");
    const workspace = await client.getWorkspace();
    const worker = await client.getWorker();

    // Get workers from the workspace
    const workerInfos = Array.from((await workspace.fetchWorkersInfo()).values());
    const targetWorkerInfo = workerInfos.find(workerInfo => workerInfo.name === "John Doe") || workerInfos[0];

    // Activities are accessible via Worker.activities property (Map of activitySID to Activity)
    const activities = Array.from(worker.activities.values());
    const targetActivity = activities.find(activity => activity.name === "Break") || activities[0];

    console.log(`Setting worker "${targetWorkerInfo.name}" activity to "${targetActivity.name}" (${targetActivity.sid})`);

    const setWorkerActivityAction = new SetWorkerActivity(targetWorkerInfo.sid, targetActivity.sid);
    await client.execute(setWorkerActivityAction);
    }

    Implements

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Parameters

      • ctx: {}

      Returns Promise<void>