The Alloy Automation Front End library provides convenient access to the pre-built modal, which allows easy access to use and embedded Alloy Automation's power into a frontend app.
Node 12 or higher.
Install the package with:
npm install alloy-frontend
# or
yarn add alloy-frontend
The Alloy Frontend Library provides a set of functions for integrating with the Alloy platform, allowing users to install, authenticate, edit, update, and perform other operations related to workflows and integrations.
To use the Alloy JavaScript Library, include the library in your project and instantiate the Alloy
object.
const Alloy = require('alloy-frontend');
const alloy = Alloy();
To use this library, you must pass over a short lived JSON Web Token generated on your backend with the User Token API. If you are using Alloy Embedded you can find that endpoint here.
Once you have the token, call the setToken
method below.
Sets the authentication token for subsequent Alloy API requests.
-
token
: The JWT token to be set.
Installs an Alloy integration or workflow.
Note: this method should ONLY be used for rendering the Alloy Embedded Modal.
-
params
: An object containing installation parameters.-
integrationId
: The ID of the integration to be installed. -
workflowIds
: An array of workflow IDs to be installed. -
callback
: A callback function to be executed after installation. -
alwaysShowAuthentication
: Boolean indicating whether to always show authentication during installation. -
hide
: Boolean indicating whether to hide the installation modal. -
title
: The title to be displayed in the installation modal. -
operation
: The operation to be performed during installation (e.g., "edit" or "update"). -
versionIds
: An array of version IDs for installation.
-
Edits an Alloy workflow with additional parameters for customization.
-
params
: An object containing edit parameters.- Inherits parameters from the
install
function.
- Inherits parameters from the
Updates an Alloy integration or workflow.
-
params
: An object containing update parameters.- Inherits parameters from the
install
function.
- Inherits parameters from the
Retrieves a list of workflows associated with the authenticated user.
Retrieves a list of integrations associated with the authenticated user.
Deactivates a workflow specified by the provided data.
-
data
: An object containing deactivation data.
Reactivates a workflow specified by the provided data.
-
data
: An object containing reactivation data.
This method is used to render the Alloy Modal for use in Unified API.
Note: this method should ONLY be used for rendering the Alloy Unified API Modal.
-
params
: An object containing authentication parameters.-
app
: The name of the application to be authenticated (e.g. "shopify"). Required if you do not specifycategory
-
category
: The name of the Unified API category to show (e.g. "commerce"). Required if you do not specifyapp
-
callback
: A callback function to be executed after authentication. -
useUnifiedSettings
: Boolean indicating whether to use unified settings. -
integrationId
: The ID of the integration for authentication.
-
const alloy = Alloy();
// Set authentication token
alloy.setToken('your-jwt-auth-token');
// [Alloy Embedded Only] – Install an integration
alloy.install({
integrationId: 'your-integration-id',
callback: (response) => {
console.log(response);
}
});
const alloy = Alloy();
// Set authentication token
alloy.setToken('your-jwt-auth-token');
// [Alloy Unified API Only] – Authenticate an application
alloy.authenticate({
app: 'your-app-name',
callback: (response) => {
console.log(response);
}
});
Make sure to replace placeholder values such as 'your-auth-token'
and 'your-integration-id'
with actual values from your Alloy account.