Description of icon
Flex UI
API Reference

StateHelper

Helper class for state.


getCurrentPhoneCallState() => Call#

Get current call state if one exists.

Returns:

  • Call | undefined

    If it does not exist.

Example:

import { StateHelper } from "@twilio/flex-ui";
const activeCall = StateHelper.getCurrentPhoneCallState();

getConversationStateForTask(task) => ConversationState.ConversationState#

Gets current chat channel state for a task.

Parameters:

Returns:

  • ConversationState.ConversationState | undefined

    Chat channel state.

Example:

import { StateHelper } from "@twilio/flex-ui";
const conversation = StateHelper.getConversationStateForTask(myConversationTask);

getReservation(reservationSid) => Reservation#

Gets TaskRouter Reservation object.

Parameters:

  • reservationSid: string

    Reservation sid to retrieve.

Returns:

  • Reservation

    Reservation instance.

Example:

import { StateHelper } from "@twilio/flex-ui";
const reservation = StateHelper.getReservation("WRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

hasPendingCall() => boolean#

Returns true if user has a pending call reservation.

Returns:

  • boolean

    If user has a pending call reservation.

Example:

import { StateHelper } from "@twilio/flex-ui";
const isCallWaiting = StateHelper.hasPendingCall();
Rate this page

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.