Using Results

In CodeFreeAI, we use a special word called {{result}} when passing data between nodes. It's like passing a baton in a relay race.


πŸƒβ€β™€οΈ Basic Principle: Relay Race

Workflows run in order. After Runner A runs, they pass the baton to Runner B, and Runner B runs with that baton.

Here, 'the baton (data) passed by the previous node' is called {{result}}.

1. {{result}}

"The baton from the person right behind me"

This is the most common method. It gets the result of the immediately preceding step.

  • Example:
    • [Node A] Result: "Apple"
    • [Node B] Input: Give me {{result}}.
    • Actual Execution: Give me "Apple".

2. {{result[0]}}, {{result[1]}} ...

"The baton from a specific person in the sequence"

Use this when you need the result of a node that ran much earlier, not just the one right before. The order starts from 0.

  • {{result[0]}}: Result of the 1st node (Start point)
  • {{result[1]}}: Result of the 2nd node
  • {{result[2]}}: Result of the 3rd node

Usage Example:

"Combine the user name from the first node () with the greeting the AI just made ()."

3. {{result[-1]}}

"The person right behind me (Re-emphasized)"

It is exactly the same as {{result}}. It means the last (most recent) item in the list.

  • {{result}} = {{result[-1]}}

πŸ’‘ Practical Example

Let's say we have a 3-step workflow:

  1. [Input] Enter User Name ("John Doe")
  2. [AI] Generate Greeting ("Hello!")
  3. [Output] Send Message

If we use data in the 3rd [Output] node?

  • If we use {{result}}?
    • πŸ‘‰ "Hello!" (Result of the immediate prior Node 2)
  • If we use {{result[0]}}?
    • πŸ‘‰ "John Doe" (Result of the first Node 1)

🍯 Pro Tips

  • In most cases, just using {{result}} is enough.
  • Use numbers like {{result[0]}} only when creating complex workflows.
  • When giving data to AI, it understands better if you explain, "This is the content of {{result[0]}}".

results matching ""

    No results matching ""