muesli / beehive

A flexible event/agent & automation system with lots of bees 🐝
GNU Affero General Public License v3.0
6.31k stars 324 forks source link

Chains of multiple actions #194

Closed Sennahoi closed 6 years ago

Sennahoi commented 6 years ago

I would like to create a chain of multiple actions, e.g.

  1. receive data from a webhook (webserver)
  2. Put this data into a script that extracts some parts
  3. Forward extracted parts to the a web client bee to send it to some endpoint

As far as it seems to me, a chain can only consist of 2 parts: An event bee and an action bee. Can I put other beens in between? Or is there another way I'm not aware of?

Thanks Johannes

larpon commented 6 years ago

Also useful when wanting to notify of some action is done

  1. Cron Every 2 minutes
  2. Execute command /do/hard/work
  3. Desktop notification - Job resulted in {{.stdout}}
LorenzoAncora commented 6 years ago

As far as it seems to me, a chain can only consist of 2 parts: An event bee and an action bee. Can I put other beens in between? Or is there another way I'm not aware of?

@Sennahoi @Larpon you can chain together multiple chains. If you have a chain, create a second chain and link its first hive to the last hive of the existing chain. You can also indirectly trigger chains by reacting to changes in the directories or the system clock.

Do not forget that if Beehive crashes you will lose all the work done: I advise you to make a backup of the chains from time to time.

larpon commented 6 years ago

Cool, thanks for your input - but how do we do this from the UI or config? I'm not sure how you link hives?

LorenzoAncora commented 6 years ago

Cool, thanks for your input - but how do we do this from the UI or config? I'm not sure how you link hives?

@Larpon it is neither easy nor intuitive but it can be done: the only way to link the hives is to exploit the fact that you can have multiple bees with the same hive but with a different name.

Example

You have 3 bees: "Cron" hive as A1, "HTTP client" hive as B1 and "Exec" hive as A2. bees

You can create 2 chains:

  1. "A1" event -> "B1" action;
  2. "B1" event -> "A2" action. chains

It works like dominoes, because the end of the first chain will trigger the second. Assuming that "A1" is triggered every hour: at the end of the first hour it will start B1 which will make an HTTP GET request; when (and if) the HTTP GET request is complete it will trigger the "get" event that will start the second chain, which will trigger A2's action.

I hope I was clear. :-)


EDIT: add screenshots.

LorenzoAncora commented 6 years ago

@Sennahoi if the problem is solved you should close the Issue. @Larpon all right? other difficulties?

Sennahoi commented 6 years ago

Thanks for your help.

LorenzoAncora commented 6 years ago

Thanks for your help.

@Sennahoi You are welcome.

larpon commented 6 years ago

@LorenzoAncora - super explanation. Thanks for your help!