# Introduction

Liteflow is a framework for developers to build applications efficiently based on MESG technology.

Liteflow is centered around the concept of processes that connect different services.

Processes can connect events and results from a service to a series of tasks from other services.

Check out the Liteflow website to learn more and see what it can do for you.

# Get started

We’ll start by showing you how to create an application triggered by a HTTP endpoint that calls a new service that displays 'hello world'.

# 1. Installation

Run the following command in a console to install the Liteflow CLI:

npm install -g @liteflow/cli

# 2. Create an application

In order to create an application, run the following command:

liteflow init get-started

Your application is now created. You can now go to the application's directory with cd get-started.

# 3. Create a 'hello world' service

liteflow service:init services/hello-world --template javascript

The service is created using a template that implements a task hello. We will use the task hello in the following process. You can get more information about this service by opening the file services/hello-word/liteflow.yml and about developing service in general, check out the service documentation.

Your service is ready to use. We will now see how to trigger it through a process.

# 4. Create a process

Our Process will define one trigger and one task from the service we previously created:

  • A http endpoint that triggers the process for every request it receives
  • The task hello from the Hello world service that checks inputs are matching "hello world" or returns an error otherwise

Let's create our first Process by creating a new YAML file (called process.yml) with the following structure:

name: hello-world
steps:
  - # TODO

# First step: Setup the trigger

To trigger the process, we are going to setup the first step to be a trigger with a endpointKey.

steps:
  - type: trigger
    endpointKey: endpointA

The endpointKey helps to create an unique URL for your process.

# Second step: Call the hello task

We want the process to execute the task hello from the service previously created. The task will be executed with inputs based on data of the previous step.

Here, we want the task's input name to contain the value of the key name of the object body of the trigger.

steps:
  - # ... trigger step
  - type: task
    instance:
      src: ./services/hello-world
    taskKey: hello
    inputs:
      name: { key: body.name }

# 5. Deploy your application

To deploy on Liteflow, make sure to be logged into the CLI with liteflow login and use the following command:

liteflow deploy

The command will automatically deploy all of your application's services and processes.

To trigger your process, execute the command (don't forget to replace the following URL with the one generated for you):

curl -XPOST https://gateway.liteflow.com/xxxxxxxx/endpointA --data name=my-name

From now on, your process will run autonomously on our blockchain-based cloud of services.

TIP

You can anytime run your application locally before publishing by using the command liteflow dev. Learn more.

# Final version of your process

Here is the final version of the process file:

name: hello-world
steps:
  - type: trigger
    endpointKey: endpointA
  - type: task
    instance:
      src: ./services/hello-world
    taskKey: hello
    inputs:
      name: { key: body.name }