Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Getting started (public beta)


(new)

Public Beta

The Flex SDK is currently available as a Public Beta product and the information contained in this document is subject to change. This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Public Beta products are not covered by a SLA.

(warning)

Not a HIPAA Eligible Service or PCI Compliant

The Flex SDK is not a HIPAA Eligible Service or PCI compliant and should not be used in workflows that are subject to HIPAA or PCI.

To get started with the Flex SDK, you'll need to use a Flex account or add Flex to your Twilio account. If you're new to Flex, see the onboarding guide(link takes you to an external page) to get started or learn more about Flex pricing(link takes you to an external page).


Develop a Flex SDK application

develop-a-flex-sdk-application page anchor

Use the following steps to develop a Flex SDK application. We'll use the vite framework here, but the Flex SDK also supports TypeScript and JavaScript.

  1. Create a directory for the new Flex SDK application.
  2. If you haven't already installed vite, run npm install -g vite.
  3. Run npm create vite@latest.
  4. Follow the wizard, and choose a vanilla project with TypeScript as the programming language.
  5. Navigate into the newly created project folder and install the Flex SDK.
  6. Run npm i @twilio/flex-sdk.
  7. Run vite with npm run dev. This runs the vite application with the Flex SDK installed.

Initializing the SDK client

initializing-the-sdk-client page anchor

In order to use Flex in a code file, include the Flex SDK and initialize the client. While we recommend using SSO, you can also use an auth token like the example below:

1
import { createClient } from "@twilio/flex-sdk";
2
3
async function createFlexClient(tokenForWorker: string) {
4
const client = await createClient(tokenForWorker, {
5
logger: { level: "debug" }});
6
return client;
7
}

Embed the Flex SDK into an existing application

embed-the-flex-sdk-into-an-existing-application page anchor

To embed the Flex SDK into an existing application, navigate to the project directory and execute the following command:

npm i @twilio/flex-sdk

This adds the Flex SDK to the project, after which you can import and initialize clients.