> For the complete documentation index, see [llms.txt](https://docs.n8n.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.n8n.io/build/code-in-n8n/use-built-in-shortcuts/langchain-code-node.md).

# LangChain Code node

n8n provides these methods to make it easier to perform common tasks in the LangChain Code node.

n8n provides these methods to make it easier to perform common tasks in the [LangChain Code node](/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.code.md).

{% hint style="info" %}
**LangChain Code node only**

The built-in methods and variables on this page are for use in expressions in the LangChain Code node. You can't use them in other nodes.
{% endhint %}

| Method                                                           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `this.addInputData(inputName, data)`                             | <p>Populate the data of a specified non-main input. Useful for mocking data.</p><ul><li><code>inputName</code> is the input connection type, and must be one of: <code>ai\_agent</code>, <code>ai\_chain</code>, <code>ai\_document</code>, <code>ai\_embedding</code>, <code>ai\_languageModel</code>, <code>ai\_memory</code>, <code>ai\_outputParser</code>, <code>ai\_retriever</code>, <code>ai\_textSplitter</code>, <code>ai\_tool</code>, <code>ai\_vectorRetriever</code>, <code>ai\_vectorStore</code></li><li><code>data</code> contains the data you want to add. Refer to <a href="/build/work-with-data/understand-n8ns-data-structure.md">Data structure</a> for information on the data structure expected by n8n.</li></ul>   |
| `this.addOutputData(outputName, data)`                           | <p>Populate the data of a specified non-main output. Useful for mocking data.</p><ul><li><code>outputName</code> is the input connection type, and must be one of: <code>ai\_agent</code>, <code>ai\_chain</code>, <code>ai\_document</code>, <code>ai\_embedding</code>, <code>ai\_languageModel</code>, <code>ai\_memory</code>, <code>ai\_outputParser</code>, <code>ai\_retriever</code>, <code>ai\_textSplitter</code>, <code>ai\_tool</code>, <code>ai\_vectorRetriever</code>, <code>ai\_vectorStore</code></li><li><code>data</code> contains the data you want to add. Refer to <a href="/build/work-with-data/understand-n8ns-data-structure.md">Data structure</a> for information on the data structure expected by n8n.</li></ul> |
| `this.getInputConnectionData(inputName, itemIndex, inputIndex?)` | <p>Get data from a specified non-main input.</p><ul><li><code>inputName</code> is the input connection type, and must be one of: <code>ai\_agent</code>, <code>ai\_chain</code>, <code>ai\_document</code>, <code>ai\_embedding</code>, <code>ai\_languageModel</code>, <code>ai\_memory</code>, <code>ai\_outputParser</code>, <code>ai\_retriever</code>, <code>ai\_textSplitter</code>, <code>ai\_tool</code>, <code>ai\_vectorRetriever</code>, <code>ai\_vectorStore</code></li><li><code>itemIndex</code> should always be <code>0</code> (this parameter will be used in upcoming functionality)</li><li>Use <code>inputIndex</code> if there is more than one node connected to the specified input.</li></ul>                         |
| `this.getInputData(inputIndex?, inputName?)`                     | Get data from the main input.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `this.getNode()`                                                 | Get the current node.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `this.getNodeOutputs()`                                          | Get the outputs of the current node.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `this.getExecutionCancelSignal()`                                | Use this to stop the execution of a function when the workflow stops. In most cases n8n handles this, but you may need to use it if building your own chains or agents. It replaces the [Cancelling a running LLMChain](https://js.langchain.com/docs/modules/chains/foundational/llm_chain#cancelling-a-running-llmchain) code that you'd use if building a LangChain application normally.                                                                                                                                                                                                                                                                                                                                                   |

## Related resources

* [Use built-in shortcuts](/build/code-in-n8n/use-built-in-shortcuts.md)
* [JMESPath](/build/code-in-n8n/use-built-in-shortcuts/jmespath.md)
* [HTTP node](/build/code-in-n8n/use-built-in-shortcuts/http-node.md)
* [n8n metadata](/build/code-in-n8n/use-built-in-shortcuts/n8n-metadata.md)
