Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Flex Manager

The Flex Manager is the access point for controlling your Flex instance and all of the underlying Twilio products used for communications and assigning tasks. This means that within your Flex project, you can access the TaskRouter or Chat client directly through the Flex manager.

Aside from Flex itself, Manager also gives you access to the Programmable Chat, Sync, Client, and TaskRouter SDKs.

Members of Manager Class

Access to Twilio SDKs

These members give read-only access to the Twilio products used within Flex.

Member Description
chatClient Access the Twilio Chat SDK - equivalent to Twilio.Chat.Client
insightsClient Access the Twilio Sync SDK - equivalent to Twilio.Sync.Client
voiceClient Access the Twilio Client (WebRTC) SDK - equivalent to Twilio.Device
workerClient Access the TaskRouter SDK - equivalent to Twilio.Taskrouter.Worker

Flex-specific members

These members give information about your specific flex instance.

Member Type Description
configuration Config Access the current Flex configuration
events FlexEventEmitter Subscribe to Flex events

serviceConfiguration

Config.ServiceConfiguration

Access the current Flex service configuration
store Store.<FlexState> Flex Redux store
strings Strings Access strings and templates for Flex. For more information on using Strings, see Localization and UI templating.
user UserInfo Access current user information

Supported methods

Method Description
create(config [, store]) Create an instance of Flex Manager
getInstance() Get the instance of Manager
fetchConfiguration() Fetch Flex configuration from the service
updateConfig(configs) Merge provided objects and update current configuration

How to obtain the Manager instance

You can access the manager as follows:

By calling the `getInstance` method

Flex.Manager.getInstance()

By calling the `create` method when initializing Flex

return Flex
    .provideLoginInfo(configuration, "#container")
    .then(() => Flex.Manager.create(configuration))
    .then(manager => {
        // use manager here
    })
    .catch(error => handleError(error));

You can check out the sample project on how to initialize Flex.

In the init method of your plugin

init(flex, manager) {
  // use manager here
}

Common use cases and examples

This example logs connect in the browser’s console whenever the agent connects to a call:

Flex.Manager.getInstance().voiceClient.on('connect', () => {
    console.log('connect');
});


By mixing calls to the Manager with the Actions Framework, you can perform more complex tasks like this example that automatically accepts all inbound chats for agents:

Flex.Manager.getInstance().workerClient.on("reservationCreated", reservation => {
    if (reservation.task.taskChannelUniqueName === 'chat' && reservation.task.direction === 'inbound') {
        Flex.Actions.invokeAction("AcceptTask", {sid: reservation.sid});
        Flex.Actions.invokeAction("SelectTask", {sid: reservation.sid});
    }
});
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 browsing the Twilio tag on Stack Overflow.