Includes
The Includes node checks if one string includes another string and outputs a boolean result.Inputs
a(string): The string to search within. This is the string that may contain the substring you are looking for.b(string): The substring to search for. This is the string that you want to check if it is included in theainput.
Outputs
result(boolean): Returnstrueif stringaincludes stringb, otherwise returnsfalse.
Configuration
This node has no additional configuration options.Usage
To use the Includes node:- Connect a string to the
ainput. This is the string you want to search within. - Connect a string to the
binput. This is the substring you want to check for inclusion ina. - The
resultoutput will emittrueifbis found withina, otherwise it will emitfalse.
Example
Let’s say you have a spell that processes customer feedback messages. You want to check if each message includes the word “great” and keep a count of the positive messages. You could use the Includes node like this:- Connect the customer message string to the
ainput. - Connect a Constant node with the value “great” to the
binput. - Connect the
resultoutput to a Filter node to only pass through messages whereresultistrue. - Connect the filtered messages to a Count node to keep a running total of positive messages.
Best Practices
- Make sure the input types match. Both inputs should be strings.
- The search is case-sensitive. Use a Transform node beforehand to convert the strings to a consistent case if needed.
- If you need to check for multiple substrings, you can chain multiple Includes nodes together with OR logic for more complex checks.
Common Issues
- Passing a non-string value to either input will cause an error. Ensure you are passing strings.
- An empty string input for
bwill always returntruesince technically an empty string is included in every string. Check your logic if you get unexpectedtrueresults.
