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:
Example: Installing all workflows in an integration
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:
Pre-filled Values Structure
Example: Installing workflows with dynamic configuration
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

