Nodes

Get Agent State#

The Get Agent State node retrieves the current state of an agent in a specified plugin. It allows you to access and use the agent's state information in your spell.

Inputs#

  • flow (required): The input flow containing the data to be processed.
  • plugin (optional): The name of the plugin where the agent is located. Default is "core". Choices include:
    • core: The default Magick core plugin.
    • discord: The Discord plugin for integrating with Discord.
    • slack: The Slack plugin for integrating with Slack.

Outputs#

  • flow: The output flow with the retrieved agent state added.
  • state: The current state of the agent as an object.

Configuration#

This node does not have any additional configuration options.

Usage#

  1. Connect the input flow to the node from which you want to retrieve the agent state.
  2. (Optional) Select the desired plugin from the dropdown menu if the agent is not in the default "core" plugin.
  3. Connect the output flow to the next node in your spell.
  4. Use the state output to access the agent's current state information in subsequent nodes.

Example#

Here's an example of how to use the Get Agent State node in a spell:

1. Start Trigger
2. Get Agent State
   - plugin: "discord"
3. Code
   - input: `state`
   - code: `console.log(state.name)`
4. Send Message
   - message: `The current agent state is: ${state}`

In this example, the Get Agent State node retrieves the state of an agent in the "discord" plugin. The state output is then passed to a Code node, which logs the agent's name to the console. Finally, the Send Message node sends a message containing the entire agent state object.

Best Practices#

  • Use the Get Agent State node when you need to access and utilize the current state information of an agent in your spell.
  • Make sure to select the correct plugin if the agent is not in the default "core" plugin.
  • Use the state output to access specific properties of the agent state object in subsequent nodes.

Common Issues#

  • If the specified plugin is not found or the agent does not exist, the node will output an empty state object.
  • Ensure that the agent has a valid state before using this node, otherwise, the state output may be undefined or empty.

By using the Get Agent State node, you can easily retrieve and work with the current state of an agent in your Magick spells, enabling more dynamic and interactive workflows.