What does it do?

Code executions let you run custom JavaScript or Python code in your Wordapp, letting you do truly anything as part of your flows. You can use code executions to manipulate data, make API calls, or even call out to AI models we don’t support (just kidding, there aren’t any).

Code executions are a powerful tool, but they’re also on the more advanced side. If you’re not comfortable with coding, you may want to check out some examples from our community or ask for help in our Discord server.

Code Execution in the Editor

How do I use it?

To create a code execution, type /code in the editor, and hit Enter. You can then write your code in the contents of the node. You can write code in either JavaScript or Python, and the code will be executed during the execution of the Wordapp.

You can @mention any variable in your flow in your code just like you would in the rest of your flow, and anything you log to the console or return from your code will be available to the rest of your flow.

Options

A number of options appear in the sidebar when you create a code execution. Here’s what they do:

Name

The name of the code execution. You’ll need this later if you want to @mention its outputs.

Language

The language you’d like to write your code in. You can choose from JavaScript or Python.

Include output in prompt

Whether the output of the code execution should be included in the prompt. If you’re using the output of the code execution in a later node, you’ll want to leave this checked. If you’re just using the code execution to manipulate data or make API calls, you can uncheck this to keep your prompt clean.

Continue on error

Whether the Wordapp should continue running if the code execution throws an error. By default, the Wordapp will stop running if a code execution throws an error, but you can check this box to keep the Wordapp running. This is particularly useful if you’re having AI iterate on writing the code itself. The AI is likely to produce invalid code at some point, and you can progressively refine it by continuing on error.

You can @mention code into a code execution node just like any other type of content. Just be careful you’re not exposing anything sensitive to prompt injection!

Outputs

Code

The code you’ve written in the code execution. This is the code that will be executed in the Wordapp.

Error

If an error occurs during the execution of the code, you’ll be able to access that error here. This can be useful for debugging your code, or passing to the AI to help it understand what went wrong, or to debug the code itself.

Logs

Any output you log to the console in your code will be available here.

Output

Anything you return from your code will be available here. This is the primary way to pass data from a code execution to the rest of your flow.