Skip to main content
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.
Our Frontend SDK makes it easy to get started with Embedded iPaaS. The Frontend SDK is used to render the Embedded iPaaS modal and manage workflow installations for your end users.

Installation

Install the package with npm:
npm install alloy-frontend
# or
yarn add alloy-frontend
Alternatively, you can install the SDK as vanilla JavaScript by adding the script tag to the header of your site:
HTML
<script
  src="https://cdn.runalloy.com/scripts/embedded.js"
  type="text/javascript"
></script>
When interacting with the Frontend Modal via vanilla JavaScript, you can access the Alloy library using the 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 the setToken method:
JavaScript
Alloy.setToken("<YOUR_TOKEN>");
All frontend SDK methods require that you first invoke setToken.

Rendering the Frontend Modal

To render the Alloy Modal for your user, call the install method. This displays the modal specific to the JWT you generated.

Standard Installation

The install method accepts the following parameters:
ParameterTypeDescription
integrationIdStringThe Id of the integration you want to display.
workflowIdsArrayAn array of workflow IDs to install. Use this to prompt users to install specific workflows.
callbackN/AA callback function invoked when the user has successfully installed their workflow from the Alloy Modal.
workflowSelectionbooleanAllows 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.
alwaysShowAuthenticationbooleanAlways 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.
hidebooleanHides 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.
titleStringShows a custom title in the Alloy Modal.
Example: Installing all workflows in an integration
JavaScript
Alloy.install({
  integrationId: "YOUR_INTEGRATION_ID",
  callback: (res) => {
    console.log({
      credentials: res.credentials,
      userId: res.userId,
    });
  },
  alwaysShowAuthentication: true,
  hide: false,
  title: "My Cool Shopify Integration",
});
Example: Installing specific workflows
JavaScript"
Alloy.install({
  workflowIds: ["YOUR_WORKFLOW_ID", "YOUR_WORKFLOW_ID"],
  callback: (res) => {
    console.log({
      credentials: res.credentials,
      userId: res.userId,
    });
  },
  alwaysShowAuthentication: true,
  hide: false,
  title: "Cool Alloy Workflows",
});

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, the install method supports additional parameters:
ParameterTypeDescription
preFilledValuesArrayPre-fills values for your end user when no configuration is required by them.
outputOverrideArrayDynamically displays available dynamic values to your end user, allowing them to configure workflow mappings.
Pre-filled Values Structure
FieldTypeDescription
fieldNamestringThe name of the field the value would be passed to.
valuestringThe value you would like to pre-fill on behalf of your end user rather than having them configure it.
displayValuestringA beautified version of the value that you want to display to your end users.
Example: Installing workflows with dynamic configuration
JavaScript
Alloy.install({
  workflowIds: ["YOUR_WORKFLOW_ID", "YOUR_WORKFLOW_ID"],
  callback: () => {
    console.log();
  },
  preFilledValues: [
    {
      workflowId: "YOUR_WORKFLOW_ID",
      connectorId: "YOUR_CONNECTOR_ID",
      data: [
        {
          fieldName: "formId",
          value: "abc123gjigwjio232r23",
          displayValue: "My Pretty Form Name",
        },
      ],
    },
  ],
  outputOverride: [
    {
      workflowId: "YOUR_WORKFLOW_ID",
      connectorId: "YOUR_CONNECTOR_ID",
      data: { "What is your name": "xyz", "What is your age": "18" },
    },
  ],
  alwaysShowAuthentication: true,
  hide: false,
  title: "Cool Alloy Title for my Cool Workflows",
});

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.
To update a workflow, invoke the 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
Alloy.update({
  workflowIds: ["YOUR_WORKFLOW_ID", "YOUR_WORKFLOW_ID"],
  callback: () => {
    console.log();
  },
  alwaysShowAuthentication: true,
  hide: false,
  title: "Cool Alloy Workflows",
});
Note that the 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. The edit method allows you to present the modal again so users can modify their configuration:
JavaScript
Alloy.edit({
  workflowIds: ["YOUR_WORKFLOW_ID", "YOUR_WORKFLOW_ID"],
  callback: (res) => {
    console.log({
      credentials: res.credentials,
      userId: res.userId,
    });
  },
  alwaysShowAuthentication: true,
  hide: false,
  title: "Cool Alloy Workflows",
});
The 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 the getWorkflows method:
JavaScript
Alloy.getWorkflows();

List all Integrations

You can list all integrations for a user by invoking the getIntegrations method:
JavaScript
Alloy.getIntegrations();

Deactivate a Workflow

You can deactivate a workflow by workflowId or name using the deactivate method:
JavaScript
Alloy.deactivate({
  workflowId: "YOUR_WORKFLOW_ID",
});

// OR

Alloy.deactivate({
  workflowName: "Shopify to Snowflake",
});

Activate a Workflow

Similarly, you can activate (or reactivate) a workflow by its workflowId or name using the reactivate method:
JavaScript
Alloy.reactivate({
  workflowId: "YOUR_WORKFLOW_ID",
});

// OR

Alloy.reactivate({
  workflowName: "Shopify to Snowflake",
});
I