Messages
Get Message History
Message History
The Message History node retrieves a specified number of recent messages from the conversation history in a Magick flow.
Inputs
flow
(required): The input flow containing the conversation history.entries
(optional): The number of message entries to retrieve from the history. Default is 10.
Outputs
flow
: The input flow, passed through unmodified.messages
: An array of the retrieved message history entries.
Configuration
hiddenProperties
: An array specifying properties to exclude from the output messages. Default is["hiddenProperties", "eventState"]
.eventState
: An array specifying additional event state properties to include in the output messages. Default is["channel", "connector"]
.
Usage
- Connect the input
flow
to the flow containing the conversation history you want to retrieve messages from. - (Optional) Set the
entries
input to the desired number of recent messages to retrieve. If not specified, the default of 10 will be used. - (Optional) Modify the
hiddenProperties
andeventState
configuration arrays to customize what data is included or excluded from the output messages. - Connect the output
messages
to any nodes that need to consume or process the retrieved message history. - The output
flow
can be used to pass the input flow through to subsequent nodes unmodified.
Example
Here’s an example of using the Message History node in a spell:
In this example, the Message History node retrieves the last 5 messages from the inputFlow
. The retrieved messages
are then passed to a custom processMessages
node for further handling.
Best Practices
- Only retrieve as many messages as you actually need to avoid unnecessary processing overhead.
- Use the
hiddenProperties
andeventState
configurations to include or exclude data properties as needed for your use case. This can help reduce the size of the output and improve performance. - Remember that the
messages
output is an array ordered from oldest to newest message. The most recent message will be the last element in the array.
Gotchas
- The Message History node only retrieves messages that are already in the flow’s history. It does not fetch any new messages that may have arrived since the flow was triggered.
- If the specified
entries
count exceeds the total number of messages in the flow’s history, the node will simply return all available messages. No error is thrown.