Note:If you are using the Frontend Modal, you must use our Frontend JavaScript SDK. For other presentation options such as the Embedded Link or Headless, the frontend JavaScript SDK is not required.
Installation
Install the package with npm:HTML
window object.
Setting Your Token
Before using any SDK methods, you must set your JWT token. As mentioned here, a JWT is required to securely authorize the user. Once you’ve retrieved your short-lived token from the Embedded APIs, set it in the frontend SDK using thesetToken method:
JavaScript
setToken.
Rendering the Frontend Modal
To render the Alloy Modal for your user, call theinstall method. This displays the modal specific to the JWT you generated.
Standard Installation
Theinstall method accepts the following parameters:
| Parameter | Type | Description |
|---|---|---|
integrationId | String | The Id of the integration you want to display. |
workflowIds | Array | An array of workflow IDs to install. Use this to prompt users to install specific workflows. |
callback | N/A | A callback function invoked when the user has successfully installed their workflow from the Alloy Modal. |
workflowSelection | boolean | Allows the end user to select which workflows they want to install. Defaults to false. When set to true, it provides a toggle-list for users to choose which workflows to install. |
alwaysShowAuthentication | boolean | Always shows the authentication step in the Alloy Modal when set to true. By default, the authentication screen is hidden if the user has already authenticated the required apps. |
hide | boolean | Hides the entire Alloy Modal if the user has already authenticated the required apps and the workflow does not require any configuration in the second step. |
title | String | Shows a custom title in the Alloy Modal. |
JavaScript
JavaScript"
Dynamic Configuration
In some cases, you may need to pre-fill values or dynamically configure workflows based on user-specific data. For example, if each of your users has a unique form with different fields, you can pass that data to Alloy to properly configure the workflow. When using dynamic configuration, theinstall method supports additional parameters:
| Parameter | Type | Description |
|---|---|---|
preFilledValues | Array | Pre-fills values for your end user when no configuration is required by them. |
outputOverride | Array | Dynamically displays available dynamic values to your end user, allowing them to configure workflow mappings. |
| Field | Type | Description |
|---|---|---|
fieldName | string | The name of the field the value would be passed to. |
value | string | The value you would like to pre-fill on behalf of your end user rather than having them configure it. |
displayValue | string | A beautified version of the value that you want to display to your end users. |
JavaScript
Updating a Workflow
When a new workflow version is released that is newer than the currently installed version, you’ll want to prompt users to upgrade to the latest version.Updating Workflows:You can tell when a workflow needs to be updated by comparing the payload returned from the List Integrations or List Workflows endpoints. When the
version is greater than the installedVersion value, you should prompt the user to update their workflow.update method. This method allows you to update a workflow and accepts the same parameters as install. The update method does not accept an integrationId and only works with workflowIds.
JavaScript
update method does not allow you to specify a version to update to. Instead, it defaults to the most recently released version (as specified by the version key in the List Workflows endpoint).
Editing a Workflow
You may want to allow users to edit a workflow after they have installed it. For example, if your user installed a workflow that sends them a message in Slack every time an event happens, they might need to customize the “channel” parameter. Later, they may decide to change their selection. Theedit method allows you to present the modal again so users can modify their configuration:
JavaScript
edit method does not accept an integrationId and only works with workflowIds.
List all Workflows
You can list all workflows for a user by invoking thegetWorkflows method:
JavaScript
List all Integrations
You can list all integrations for a user by invoking thegetIntegrations method:
JavaScript
Deactivate a Workflow
You can deactivate a workflow byworkflowId or name using the deactivate method:
JavaScript
Activate a Workflow
Similarly, you can activate (or reactivate) a workflow by itsworkflowId or name using the reactivate method:
JavaScript

