Frontend JavaScript SDK

Alloy Automation Front End Library

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.

Installation

Install the package with:

npm install alloy-frontend
# or
yarn add alloy-frontend

Usage

Overview

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.

Installation

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();

Setup

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.

setToken(token)

Sets the authentication token for subsequent Alloy API requests.

  • token: The JWT token to be set.

Methods

authenticate(params)

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 specify category
    • category: The name of the Unified API category to show (e.g. "commerce"). Required if you do not specify app
    • 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.

Usage Example

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);
  }
});

Reminders

Make sure to replace placeholder values such as 'your-auth-token' and 'your-integration-id' with actual values from your Alloy account.