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

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

boolean or data function

If condition

trigger

string, data function, or null

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

message

string, object, or data function

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 ...

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

Last updated

Was this helpful?