Remote manual control of RTMS streams

Remote manual control of RTMS streams

RTMS for Contact Center allows you to manually control your streams to start, pause, and stop when appropriate. To use this method, the following is required:

  • Within your app integration settings, toggle the "auto" switch based on your needs: off to manually start, stop, and pause streams, or on to auto-start streams with the option to manually stop and pause
  • An account with admin privileges and an RTMS license
  • The contact_center_rtms:write:admin scope must be added to the application

To control the stream of a specific engagement, make a call to the update engagement RTMS app status endpoint, authorized with your account's bearer token. Construct your request as outlined here:

  • The specific engagement ID (must be for an active engagement) is added as a query parameter in your PUT request
  • The specified action to be implemented: start, stop, pause, resume
  • Within settings, the client ID of your authorized application

Constructing an API call

With manual control, admins can manage RTMS streams from separate applications. Using the engagement ID of the selected active engagement, the endpoint can be constructed:

https://api.zoom.us/v2/contact_center/LjjdDBo5SkGneP8qY4SvuQ/rtms_app/status

Make a PUT request to the endpoint. This can be called programmatically or dynamically based on your design. For example, if a stream is designed to end 32 minutes after the call starts, a component might look like this:

async function stopRTMS(engagementId, accessToken) {
    const response = await fetch(
        `https://api.zoom.us/v2/contact_center/open_engagements?engagement_id=${engagementId}`,
        {
            headers: { Authorization: `Bearer ${accessToken}` },
        },
    );
    const data = await response.json();
    const start_time = data.engagements.start_time;
    setTimeout(
        () => {
            fetch(
                `https://api.zoom.us/v2/contact_center/${engagementId}/rtms_app/status`,
                {
                    method: "PUT",
                    headers: {
                        Authorization: `Bearer ${accessToken}`,
                        "Content-Type": "application/json",
                    },
                    body: JSON.stringify({
                        action: "stop",
                        settings: { client_id: "YOUR_CLIENT_ID" },
                    }),
                },
            );
            // Calculate: call start time + 32 minutes - current time = time until stop
        },
        new Date(start_time).getTime() + 32 * 60 * 1000 - Date.now(),
    );
}

Admins can also pause and resume a stream using manual control. The example code below shows these actions tied to user interactions, such as an admin pressing a button in a remote application.

let paused = false;
button.onclick = async () => {
    paused = !paused;
    await fetch(
        `https://api.zoom.us/v2/contact_center/${engagementId}/rtms_app/status`,
        {
            method: "PUT",
            headers: {
                Authorization: `Bearer ${accessToken}`,
                "Content-Type": "application/json",
            },
            body: JSON.stringify({
                // Add "action" value conditionally, maintaining one button
                action: paused ? "pause" : "resume",
                settings: {
                    client_id: "YOUR_CLIENT_ID",
                },
            }),
        },
    );
    // Render button text based on stream status
    button.textContent = paused ? "Resume RTMS" : "Pause RTMS";
};

Flow script

Manual control also makes it possible to manage your stream status with your flow. Using the script widget, admins can tie the start of an RTMS stream, for instance, to a specific flow event. The example below outlines a stream being started based on the consumer's consent, indicated with a button press.

Example walkthrough

Input is collected from the consumer using the "collect input" widget. For the sake of this demo, the widget has been descriptively named "RTMSConsent". Appended as the next step, the script widget is used to make the API call and start RTMS.

In this scenario, a conditional based on consumer input is used to determine script invocation. It will only be called if the entered digit (captured using the var_get built-in function) matches that of consent, as communicated to the consumer. Below is the customization applied to the "collect input" widget to ensure this functionality.

Finally, here is an example script to make the PUT request to the endpoint, indicating "start" as the action. As shown on line 2 and described above, this function captures consumer input by finding the pre-set "Digits" value in our "collect input" object (named RTMSConsent in this scenario).

async function main() {
    const input = var_get()["RTMSConsent.Digits"];
    if (input == 1) {
        await req.put(
            `https://api.zoom.us/v2/contact_center/${var_get()["engagementId"]}/rtms_app/status`,
            {
                data: {
                    action: "start",
                    settings: {
                        client_id: "YOUR_CLIENT_ID",
                    },
                },
            },
        );
        log.info("RTMS stream started");
    }
    return;
}

While this action was tied to user input at the beginning of the call, admins can design their flow and stream management in the way that best suits their needs, making use of the script widget to make the API call.

Conclusion

Manual control of RTMS streams gives Contact Center administrators the flexibility to manage media streams precisely when needed. Whether implementing time-based automation, responding to user interactions, or integrating stream control into call flows, the RTMS API provides powerful customization options for your streaming experience.

Get started and begin building your custom stream management solution today!