> ## Documentation Index
> Fetch the complete documentation index at: https://docs.refold.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Internal Functions

> Create reusable functions or provides built-in, non-editable library functions in workflows.

A Custom Code node is used to solve any data-related issues that required coding in the workflows. If the same code was needed at multiple places, the users need to use a Custom code node with the same code in different workflows.

<Info>
  If you want to learn more about Custom Code Node, refer [here](https://docs.gocobalt.io/build/workflow/custom-code).
</Info>

To reduct this repetitive process, the solution is the Functions node. Using this, you can create reusable functions at the global level for your Refold account, which can then be used inside workflows.

## Create your Functions

You can create your own functions to be used in the node by providing three things:

* Code for the function
* Input fields
* Output fields.

To create your own function, follow these steps:

<Steps>
  <Step title="Navigate">
    In the Refold dashboard, navigate to `Functions` under **Advanced** in the side menu.
  </Step>

  <Step title="Create function">
    Click on `+ Create Function` button and provide its **Name**.

    <img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Guides/Nodes/functions_create.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=93cdb705dd08169fde19eaf21b23d7fc" alt="Create Functions" data-path="images/Guides/Nodes/functions_create.png" />
  </Step>

  <Step title="Write function">
    Write your function and also define the input and output parameters that you require.
    Once done, click on `Create`.

    <Info>
      You can also use JavaScript Libraries supported by Refold in the function code. Refer [here](/build/workflow/internal_functions#supported-javascript-libraries-and-usage) to check the list of supported libraries.
    </Info>
  </Step>
</Steps>

<Tip>
  Once a function is created, you can also edit it as required by selecting that function from `Functions`.
</Tip>

## Supported JavaScript Libraries & Usage

The full list for the supported npm modules that can be used to write your own internal function is below. If you don't see the module that you want, [contact us](mailto:integrations@gocobalt.io) and we will get that added.

* [axios](https://www.npmjs.com/package/axios)
* [cheerio](https://www.npmjs.com/package/cheerio)
* [date-fns](https://www.npmjs.com/package/date-fns)
* [fast-xml-parser](https://www.npmjs.com/package/fast-xml-parser)
* [fuse.js](https://www.npmjs.com/package/fuse.js)
* [lodash](https://www.npmjs.com/package/lodash)
* [mime](https://www.npmjs.com/package/mime/v/3.0.0)
* [number-to-words](https://www.npmjs.com/package/number-to-words)
* [url](https://www.npmjs.com/package/url)
* [uuid](https://www.npmjs.com/package/uuid)
* [danfo](https://danfo.jsdata.org/getting-started)

**How to use Libraries**

To know how you can use these external libraries in your Internal Code function, refer to the examples below for axios and lodash.

<CodeGroup>
  ```JavaScript axios theme={null}
  const axios = require('axios');

  async function yourFunction(params) {
      const res = await axios.get("https://genshin-impact.up.railway.app/characters");

      return{
          data: res.data
      }
  }
  ```

  ```JavaScript danfo theme={null}
  const dfd = require('dfd')
  function yourFunction(params) {
      const s = new dfd.Series([1, 3, 5, undefined, 6, 8])
      return dfd.toJSON(s)
  }
  ```

  ```JavaScript lodash theme={null}
  const _ = require('lodash');

  function yourFunction(params) {
      const array = [{ id: 3 }, { id: 1 }, { id: 2 }];
      const sortedData = _.sortBy(array, "id");

      return {
          data: sortedData
      };
  }
  ```
</CodeGroup>

## Pre-defined Library functions

You can also use some pre-defined functions, also known as Library functions offered by Refold. These functions show up in the Functions node by default and can't be edited.

Few of the library functions are:

* Find element in array,
* Encrypt string,
* Get current date; & many more.

Once you select a function, simply provide the required inputs to perform it.

<img height="200" src="https://mintcdn.com/cobalt-55/yYFE4rj1UK1LIP4D/images/Guides/Nodes/functions.png?fit=max&auto=format&n=yYFE4rj1UK1LIP4D&q=85&s=78134a86d0318a32d234173cc772110f" alt="Library Functions" data-path="images/Guides/Nodes/functions.png" />
