# Run Flows Configured Online

Use this path when the module order and settings live on the Incode Dashboard rather than in your app. Instead of defining a `flowConfig` array locally, you reference a Workflow or Flow by ID and the SDK runs the modules and configuration applied to it on the Dashboard. This lets you change the configuration without shipping a new app build.

Workflows and Flows are different Dashboard artifacts, and the method you call depends on which one your configuration is: `startWorkflow()` requires a Workflow's `configurationId`, `startFlow()` requires a Flow's `configurationId`.

> **Before you start**
>
> Make sure the SDK is installed and initialized. See [Getting Started](../react-native-getting-started/index.md) for setup and initialization.

For the modules a Workflow or Flow can include, see [Modules](../react-native-modules.md). For the result and error objects delivered to listeners, see [Results](../react-native-results.md).

## Register step listeners

If you want to react to individual modules as they complete, register listeners before starting the session. If you only need the final outcome, you can rely on the value returned by the start call and skip this step.

```ts
const unsubscribers = [
  IncodeSdk.onSessionCreated((session) => {
    console.log(session.interviewId);
  }),
  IncodeSdk.onStepCompleted({
    module: 'IdScanFront',
    listener: (event) => console.log(event.result),
  }),
  IncodeSdk.onStepCompleted({
    module: 'IdScanBack',
    listener: (event) => console.log(event.result),
  }),
  IncodeSdk.onStepCompleted({
    module: 'ProcessId',
    listener: (event) => console.log(event.result.extendedOcrData),
  }),
  IncodeSdk.onStepCompleted({
    module: 'SelfieScan',
    listener: (event) => console.log(event.result),
  }),
  IncodeSdk.onStepCompleted({
    module: 'FaceMatch',
    listener: (event) => console.log(event.result),
  }),
];
```

Call each unsubscriber when the screen unmounts:

```ts
React.useEffect(() => {
  const unsubscribers = setupListeners();

  return () => {
    unsubscribers.forEach((unsubscriber) => unsubscriber());
  };
}, []);
```

Because the modules are defined on the Dashboard, the listeners you register here should correspond to the modules included in the Workflow or Flow. For the shape and fields of each result object passed to these listeners, see [Results](../react-native-results.md).

❗{/* [SME input needed: source-level review confirmed that the same listener mechanism works for Dashboard-configured and locally-configured sessions, but couldn't confirm which specific module events fire for Dashboard-configured sessions (this depends on backend/business logic). Confirm which events customers can rely on when running Dashboard-configured sessions. Escalation candidate: needs Dashboard/product knowledge.] */}

## Configure the session

Build a `sessionConfig` with the `configurationId` of the Workflow or Flow to run. Ensure the Workflow or Flow is activated on the Dashboard before starting the session.

Useful `sessionConfig` fields for Dashboard-configured sessions include:

| Field                               | Use                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `configurationId`                   | The Workflow or Flow ID from the Dashboard. The modules and configuration applied to it are used for this session.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `externalId` / `externalCustomerId` | Link the Incode session to your own user/customer ID. With `externalId`, if a session with the same ID already exists and the previous session was interrupted, that session is resumed instead of a new one being created. With `externalCustomerId`, a new session is always created even if one with the same ID already exists. {/* [SME input needed: source-level review couldn't confirm the resume-vs-create distinction between `externalId` and `externalCustomerId`; this is backend session-management behavior. Confirm expected behavior. Escalation candidate: needs backend/product knowledge.] */} |
| `interviewId` / `token`             | Start from a backend-created session.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `queue`                             | Assign the session to a queue.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `validationModules`                 | Select server-side validation modules.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `customFields`                      | Attach custom string data to the session.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `e2eEncryptionEnabled`              | Enable E2EE for the session. See [End-to-End Encryption](../react-native-sdk-getting-started/react-native-e2ee.md) for the full setup.                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `mergeSessionRecordings`            | Merge recordings from ID capture and Face capture into a single video.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `voiceConsentLanguage`              | Set `VideoSelfie` voice consent language: `en`, `es`, `pt`, or `he`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |

Example:

```ts
const sessionConfig = {
  configurationId: 'YOUR_CONFIGURATION_ID',
  externalId: 'external-id',
};
```

## Start the session

The React Native SDK provides separate entry points for running a Workflow versus a Flow:

| Entry point               | Use when                                                                                                                  |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `startWorkflow()`         | Running a Workflow configured on the Dashboard.                                                                           |
| `startFlow()`             | Running a Flow configured on the Dashboard. Optionally start from a specific step using `moduleId`.                       |
| `startFlowFromDeepLink()` | Resuming a Flow from a deep link URL. The SDK reads the `configurationId`, `interviewId`, and starting step from the URL. |

If you're not sure whether your Dashboard configuration is a Workflow or a Flow, check under **Flow Builder > Flows** or **Flow Builder > Workflows** on the Dashboard.

#### Run a Workflow

```ts
const result = await IncodeSdk.startWorkflow({
  sessionConfig: {
    configurationId: 'YOUR_CONFIGURATION_ID',
  },
});
```

#### Run a Flow

```ts
const result = await IncodeSdk.startFlow({
  sessionConfig: {
    configurationId: 'YOUR_CONFIGURATION_ID',
    externalId: 'external-id',
  },
});
```

Start from a specific module by passing `moduleId`:

```ts
await IncodeSdk.startFlow({
  sessionConfig: {
    configurationId: 'YOUR_CONFIGURATION_ID',
  },
  moduleId: 'EMAIL',
});

await IncodeSdk.startFlow({
  sessionConfig: {
    configurationId: 'YOUR_CONFIGURATION_ID',
  },
  moduleId: 'PHONE',
});
```

For the full list of valid `moduleId` values, see [valid `moduleId` values](../react-native-api-reference.md#valid-moduleid-values) in the API Reference.

#### Resume a Flow from a deep link

Use `startFlowFromDeepLink()` to resume a Flow from a deep link URL. Deep links work for Flows only, not Workflows:

```ts
const result = await IncodeSdk.startFlowFromDeepLink('YOUR_DEEPLINK_URL');
```

The deep link URL follows this ``ormat: `https://[host]/[path]/[flowId]?interviewId=[interviewId]&module=[module]``, where:

- `flowId` (required, path segment): the Flow's configuration ID.
- `interviewId` (optional, query parameter): the ID of the interview session to resume.
- `module` (optional, query parameter): the module to start from.

If your app receives a shortened URL, pass `true` as the second argument:

```ts
const result = await IncodeSdk.startFlowFromDeepLink('YOUR_DEEPLINK_URL', true);
```

Deep links are typically generated by your backend or the Incode Dashboard.

## Related pages

- [Common Implementation Patterns](index.md): choose the integration pattern that fits your app.
- [Configure Flows Locally and Run End to End](react-native-configure-flows-locally-and-run-end-to-end.md): define the full flow in code instead of on the Dashboard.
- [Configure Flows Locally and Run Step by Step](react-native-configure-flows-locally-and-run-step-by-step.md): split a locally configured flow into sections.
- [Modules](../react-native-modules.md): the modules a Workflow or Flow can include.
- [Results](../react-native-results.md): result and error objects returned by listeners and start calls.
- [API Reference](../react-native-api-reference.md): full API specification.

<br />
