Integration Development Kit

Integration Development Kit (IDK) is a framework, designed to facilitate the rapid development of reusable components that extend the base functionality of the Layer platform. It will provide a mechanism for the development and deployment of integrations within serverless infrastructure.

The framework is developed using Serverless, an abstraction layer over the cloud function functionality available from Amazon AWS and Microsoft Azure. Serverless was selected because it allows Layer developers to embrace a unified workflow regardless of the cloud provider that the integration is deployed to.

Library

The IDK JavaScript Library, @layerhq/idk, supplies abstractions for Layer Webook verification, validation, and JSON parsing as well as abstractions for REST API calls for Identities, Conversations, and Messages.

The library may be added to your integration using NPM package manager by running:

npm install --save @layerhq/idk

Project structure

The IDK works best when the command-line tool is used in conjunction with the JavaScript library. The JavaScript library is used for the development of the integration, and the command-line tool is used for the deployment of it.

To be successful, it’s important that the project is structured as outlined in this document. It combines the foundation of the Serverless technology and certain Layer requirements.

At minimum this is project folder structure:

<provider>/
|-- src/
|   |-- config.js
|   |-- handlers.js
|   |-- layer_config.json
|-- layer_manifest.yml
|-- package.json
|-- serverless.yml
common/
|-- index.js
|-- package.json

<provider>

Each Serverless Cloud Provider implementation is contained at a top level.

The source folder src/ contains cloud function handlers, database persistence implementation and other provider specific code. All service configuration is contained in the serverless.yml file.

Manifest File

Manifest YAML layer_manifest.yml file contains all the necessary configuration values to drive the provisioning process.

Example:

name: 'My Awesome Integration' # Descriptive integration name
provider: aws # Serverless Cloud Provider

webhook: # Layer Webhook events
  events:
    - Message.created

input: # Input values that drive provisioning process
  -
    key: awesome_api_key # Key being used for the output layer_config.json file
    type: text # Input type (text, number, email)
    default: null # Default value (if not required)
    name: Awesome API key
    description: API key for the Awesome Service
    required: true

Each cloud provider has it’s own manifest file because the installation process can differ. Some providers require additional input values such as database keys and other credentials.

Configuration File

Configuration file layer_config.json contains all the necessary values to deploy and run the integration. It is the output of provisioning process.

Example:

{
  "app_id": "layer:///apps/staging/ffffffff-ffff-ffff-ffff-ffffffffffff",
  "webhook": {
    "secret": "my_webhook_secret",
    "events": [
      "Message.created",
    ]
  },
  "api": {
    "token": "abcdefghijklmnopqrstuvqxyz"
  },
  "awesome_api_key": "my_awesome_key"
}

common

Common folder contains all the code that can be shared within the integration and used by provider code. Common is a local NPM package which is a dependency installed by the provider.