-
-
Notifications
You must be signed in to change notification settings - Fork 325
Actions
Actions are methods a Bee offers you and which can get called by one of your Chains. Just like Events get triggered with a set of parameters, Actions expect you to pass a set of parameters to them.
Each Action will require different parameters. Just as an example, there's TwitterBee's tweet
Action, which expects only one parameter, called status
. Whatever you set this parameter to, when tweet
gets called, it will post a new tweet with that value.
Naturally it would be pretty boring if you could only set a fixed value for each Action parameter in your Chain. That's why you can reference all of the Event's parameters, too.
Let's say you have a Chain, which connects RSSBee's new_item
Event with TwitterBee's tweet
Action. In other words: whenever there's a new item added to the RSS feed, you want to post a new tweet. Let's set the tweet
Action's status
parameter to something meaningful:
RSS feed updated: {{.title}}
{{.title}}
will get replaced by the content of the Event parameter called title
. So if there's a new RSS feed item with the title Just a test
, this will post a tweet with the content RSS feed updated: Just a test
.
RSSBee also has access to the links in RSS feed entries. In order to access a specific array index in the .links
parameter, you can use the Index
action helper: {{index .links 0}}
RSS feed updated: {{.title}} {{index .links 0}}
More advanced actions can contain helper functions as well. For instance, if you have a discord bot with multiple arguments (i.e. ".light red 255", for a chain involving discord and Philips Hue), you can set the light color in the chain via:
{{index (Split .contents " ") 1}}
And you can set the light brightness via:
{{index (Split .contents " ") 2}}
Likewise, if you had a Discord Bot that took messages with the ".mastodon" prefix and shipped them to Mastodon, you could strip the ".mastodon" prefix with:
{{(Replace .contents ".mastodon" "" 1)}}