LetsFlow
  • Introduction
  • Tutorial
    • The basics
    • A handshake
    • A conversation
    • A proper introduction
    • Group meeting
    • Quote
  • Cookbook
  • ENGINE
    • Installation
    • Authentication
    • API
    • Services
      • Configuration
      • Messaging
        • ZeroMQ
        • AMQP 0-9-1
        • Webhook
      • Engine service
  • Integration
    • Frontend
      • React
      • Angular
      • Vue
      • Svelte
    • Backend
  • Reference
    • Scenario
      • Actor
      • Action
        • Update instruction
      • State
        • Transition
          • Log
        • Notify
      • Data function
    • Schema
    • Process
      • Current state
      • Previous log
      • Prediction
      • Events
        • Instantiate event
        • Action event
        • Timeout event
  • Libraries
    • Core library
    • JMESPath
    • Test suite
      • Given
      • When
      • Then
        • Assert state
        • Assert actor
        • Assert variable
        • Assert service
        • Assert event
      • Customize
  • Advanced topics
    • Deep integration
    • Decentralized workflows
    • Custom JMESPath functions
    • Custom YAML tags
Powered by GitBook
On this page
  • Implicit notify
  • Properties
  • service
  • after
  • if
  • trigger
  • message
  • Standard message
  • process
  • actions
  • instructions

Was this helpful?

  1. Reference
  2. Scenario
  3. State

Notify

Automation in LetsFlow is handled by your backend or microservices. When a state transition occurs, the service needs to be notified. This is achieved through messaging.

If you're using the workflow engine, notifications are sent via a messaging queue or webhooks. However, if you're integrating the core library directly into your backend, you can leverage the event system provided by your framework to handle these notifications efficiently.

Implicit notify

For any action available for a service, a notify instruction is automatically appended to that state. The service can be referenced in the by property of a state transition or the actor property of an action.

If there's exactly one action that the service can perform, the trigger property is automatically set to that action. If multiple actions are available the trigger property is set to null.

initial:
  on: create_document
  by: service:cms
  goto: main
{
  "initial": {
    "on": "create_document",
    "by": "service:cms",
    "goto": "main"
  }
}

Properties

service

string (required)

The service to message

after

time

Delay notifying the service.

The time should be in the form of 'amount unit' in English, eg '10 minutes', '12 hours`, or `1 week`.

if

If condition

trigger

The action that the service has performed when giving a response.

If the service provides a response and multiple actions are available to the service, you should use a data function to determine which action has been executed. The data function is evaluated after receiving a response and not when the state is instantiated.

initial:
  transitions:
    - on: continue
      by: service:agent
      goto: main
    - on: cancel
      by: service:agent
      goto: (cancelled)
  notify:
    service: agent
    trigger: !ref current.response.action
{
  "initial": {
    "transitions": [
      {
        "on": "continue",
        "by": "service:agent",
        "goto": "main"
      },
      {
        "on": "cancel",
        "by": "service:agent",
        "goto": "(cancelled)"
      }
    ],
    "notify": {
      "service": "agent",
      "trigger": {
        "<ref>": "current.response.action"
      }
    }
  }
}

message

Custom message to send the service.

Standard message

If message is omitted, the standard message is sent. This is;

process

actions

array of instantiated actions

The actions that the service is allowed to perform in the current state.

instructions

string

Instructions for the service as defined in the scenario for this state.

wait_on_agent:
  on: respond
  by: service:agent
  goto: wait_on_user
  instructions:
    service:agent: |
      Based on the conversation answer ...
{
  "wait_on_agent": {
    "on": "respond",
    "by": "service:agent",
    "goto": "wait_on_user",
    "instructions": {
      "service:agent": "Based on the conversation answer ..."
    }
  }
}

Instructions are mostly useful when the service is an AI agent.

PreviousLogNextData function

Last updated 2 months ago

Was this helpful?

boolean or

string, , or null

string, object, or

data function
data function
data function