1.1.0 • Published 3 months ago

@anthill.technology/amplify-cli v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

Amplify CLI reference

The Amplify CLI is a command-line interface that provides a variety of tools for managing, viewing, and deploying plugins.

Commands

The command amplify --help lists the available commands and amplify <command> --help shows more details for an individual command.

Below is a brief list of the available commands and their function:

   ____                                          _       _     _              ___       _             __                   __                 _                    _ _  __
  / ___|___  _ __ ___  _ __ ___   __ _ _ __   __| |     | |   (_)_ __   ___  |_ _|_ __ | |_ ___ _ __ / _| __ _  ___ ___   / _| ___  _ __     / \   _ __ ___  _ __ | (_)/ _|_   _
 | |   / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` |_____| |   | | '_ \ / _ \  | || '_ \| __/ _ \ '__| |_ / _` |/ __/ _ \ | |_ / _ \| '__|   / _ \ | '_ ` _ \| '_ \| | | |_| | | |
 | |__| (_) | | | | | | | | | | | (_| | | | | (_| |_____| |___| | | | |  __/  | || | | | ||  __/ |  |  _| (_| | (_|  __/ |  _| (_) | |     / ___ \| | | | | | |_) | | |  _| |_| |
  \____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|     |_____|_|_| |_|\___| |___|_| |_|\__\___|_|  |_|  \__,_|\___\___| |_|  \___/|_|    /_/   \_\_| |_| |_| .__/|_|_|_|  \__, |
                                                                                                                                                            |_|            |___/
Usage: amplify [options] [command]

Command-Line Interface for Amplify

Options:
  -V, --version            output the version number
  -h, --help               display help for command

Commands:
  login [options]          log the CLI into Amplify.
  logout                   log the CLI out of Amplify.
  use [options]            set an active organization for your working directory.
  plugin:create [options]  creates a new plugin in Amplify.
  plugin:deploy [options]  deploys a new plugin in Amplify.
  plugin:delete [options]  deletes a plugin from Amplify.
  plugin:list [options]    list the available plugins in Amplify.
  help [command]           display help for command

Installation

To download and install the Amplify CLI run the following command:

npm install -g @anthill.technology/amplify-cli

This will provide you with the globally accessible amplify command.

Usage

Log in the Amplify CLI

After installing the CLI, you must authenticate. Log into Amplify using your account by running the following command:

amplify login

Test that the CLI is properly installed and accessing your account by listing your organizations. Run the following command:

amplify use

You will be prompted to select an active organization. To change the active organization re-run the above command.

List available plugins

To view existing plugins. Run the following command:

amplify plugin:list

Create a new plugin

To create a new plugin. Run the following command:

amplify plugin:create

You will be prompted to select a plugin type, and a name for the plugin. A new directory will be created in your local path using the name of the plugin.

tree ./example-plugin

./example-plugin
├── config.js
├── index.js
└── package.json

The directory contains the following structure. For more information regarding supported schemas based on each plugin type, see schemas.

Deploy an existing plugin

To deploy a new plugin. Run the following command:

amplify plugin:deploy --directory <path-to-folder>

To redeploy an existing plugin, re-run the above command.

Schema

Config.js

Represents the configuration object of the Plugin, with an optional settings array.

module.exports = {
  id: string,
  name: string,
  type: string,
  settings: [
    {
      id: string,
      required: boolean,
      type: string,
      label: string,
      hint: string,
    },
    {
      id: string,
      required: boolean,
      type: 'selectList',
      options: [
        { label: string, value: string },
        { label: string, value: string },
      ],
    },
  ],
};
  • id: The unique identifier for the plugin (autogenerated from the plugin:create command).
  • name: The display name of the plugin.
  • type: The plugin type. Supported values are: message, buttonGroup, carousel, embedded, goTo, question and player
  • settings: Variables that can be configured when the plugin is configured in the editor.
    • id: The key used to reference the setting.
    • required: If true then the settings must have a value.
    • type: Identifies what kind of input method the settings has. Supported values are string, boolean and selectList.
    • options: If the settings type is selectList then it is necessary to define the possible input values.
    • label (optional): The display name of the setting. If this isn't defined, then the id key will be used as the display name.
    • hint (optional): A descriptive hint to render with the plugin setting to explain what can be configured with it.

Index.js

Based on the plugin type, the following schemas are required.

General setup of all types

The general setup of each plugin type is the following:

exports.handler = async (params) => {
  return {
    type: '<NODE_TYPE>',
    delay: 2,
    ...
  };
};

Where the params object consists of:

  • params: The available configration for the plugin.
    • settings: An object of the settings defined in config.js with their values defined by the editor in the builder.
    • context: All the storage values defined for the amp with their assigned value in the user's context.

And the handler method returns an object of the rendered node, which always (no matter which type of plugin it is) consists of:

  • type: The type of node to be rendered.
  • delay: How long a delay in seconds there should be for the node to be rendered (the chatbot renders a typing animating during the delay).

Message

exports.handler = async (params) => {
  // ...
  return {
    type: 'message',
    delay: 1,
    html: '<html></html>',
  };
};

Button Group

exports.handler = async (params) => {
  // ...
  return {
    type: 'buttonGroup',
    delay: 1,
    subNodes: {
      '<UUID>': {
        id: '<UUID>',
        sortIndex: 0,
        buttonTexts: ['Yes', 'No'],
      },
    },
  };
};

Carousel

exports.handler = async (params) => {
  // ...
  return {
    type: 'carousel',
    delay: 1,
    subNodes: {
      '<UUID>': {
        id: '<UUID>',
        sortIndex: 0,
        headline: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
        description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vel nunc quis orci commodo laoreet sit amet ac odio.',
        email: {
          address: 'ullman@yahoo.com',
          subject: 'Lorem ipsum dolor sit amet',
          title: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
        },
        link: {
          title: 'Lorem Picsum',
          url: 'https://picsum.photos/200/300',
        },
        media: {
          title: 'Lorem Picsum',
          type: 'image',
          url: 'https://picsum.photos/200/300',
        },
      },
    },
  };
};

Embedded

exports.handler = async (params) => {
  // ...
  return {
    type: 'embedded',
    delay: 1,
    title: 'Lorem ipsum',
    embedUrl: 'https://path.to.the.embedded.url',
    successMessageEvent: '<postMessage.success_event.name>',
    returnOnSuccess: false,
  };
};

Go To

exports.handler = async (params) => {
  // ...
  return {
    type: 'goTo',
    delay: 1,
    conversationId: '<CONVERSATION_ID>,
  };
};

Question

exports.handler = async (params) => {
  // ...
  return {
    type: 'question',
    delay: 1,
    html: '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>',
    buttonsDelay: 2,
    subNodes: {
      '<UUID>': {
        id: '<UUID>',
        sortIndex: 0,
        buttonTexts: ['Yes', 'No'],
      },
    },
  };
};

Player

exports.handler = async (params) => {
  // ...
  return {
    type: 'player',
    delay: 1,
    media: {
      url: 'https://path.to.media.asset',
      title: 'media_file_name.mp3',
      type: 'audio',
    },
    headline: 'Lorem ipsum',
    description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
    autoPlay: false,
  };
};