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

# Modules

> Reference for npm modules available in Cognigy Code Nodes, including Moment.js, Lodash, and other preinstalled packages for data manipulation.

In a Code Node, you can use a selection of predefined NPM modules. On this page, you'll find all the necessary information to run these modules in a Code Node.

> [accordion] Moment.js
>
> You can use the moment.js module for parsing, validating, manipulation and displaying dates.
>
> ## **Usage**
>
> In a Code Node, call the following function:
>
> ```js theme={null}
> moment(inp?:any, format?: any, strict?: boolean);
> ```
>
> ## **Example**
>
> the following example gets the current UTC time and date and outputs it back to the contact.
>
> ```js theme={null}
> const utc = moment.utc();
> api.output(utc);
> ```
>
> For more information, see the [Moment.js Documentation](https://momentjs.com/docs/).

> [accordion] Lodash
>
> [Lodash Documentation](https://lodash.com/docs/4.17.10)
>
> Cognigy also supports the utility library Lodash within Code Nodes.
>
> ## **Usage**
>
> You can call functions of the Lodash module by using the following syntax:
>
> ```js theme={null}
> _.keys(<OBJECT>);
> ```
>
> You can use any Lodash function within a Code Node. See their [documentation](https://lodash.com/docs/4.17.10) for further information.
>
> ## **Example**
>
> The following example shows a typical use-case and syntax of the Lodash module.
>
> ```js theme={null}
> const favouriteFoods = ["pizza", "spaghetti", "burger"];
> const last = _.last(favouriteFoods);
> api.output(last);
> ```
>
> In this example we're extracting the last element of the `favouriteFoods` array and sending it as an output message.

> [accordion] Messenger Platform
>
> [XML-js Documentation](https://www.npmjs.com/package/xml-js)
>
> In case you want to parse XML data, you can use this module.
>
> ## **Usage**
>
> Within a Code Node, you can call the following method:
>
> ```js theme={null}
> const xml =
>     '<?xml version="1.0" encoding="utf-8"?>' +
>     '<note importance="high" logged="true">' +
>     '    <title>Happy</title>' +
>     '    <todo>Work</todo>' +
>     '    <todo>Play</todo>' +
>     '</note>';
>
> const result = xmljs.xml2json(xml, { compact: true, spaces: 4 });
>
> // result will now contain a JSON representation of the xml above
> ```

> [accordion] Text Cleaner
>
> ## **Usage**
>
> Within a Code Node, you can invoke the `getTextCleaner` function, which retrieves an instance of the [Text Cleaner](https://docs-classic.cognigy.com/ai/platform-features/nlu/text-cleaner.md) class.
> This class provides access to various text-cleaning functions.
>
> **Parameters**
>
> | Parameter | Type | Description |
> | - | - | - |
> | locale | string | The locale for which to instantiate the class. For example, 'de' or 'en'. |
> | options | object | See below for the config options. |
>
> **Config Options**
>
> ```json theme={null}
> {
>     // additional characters which won't be cleaned by cleanDisallowedSymbols
>     additionalAllowedCharacters: string[], 
>
>     // additional symbols which are replace (for example, "minus": "-")
>     additionalMappedSymbols: { [key: string]: string }, 
>
>     // additional phrases which are replaced
>     additionalSpecialPhrases: { [key: string]: string }, 
>
>     // additions to the phonetic alphabet (for example, "cognigy": "c")
>     additionalPhoneticAlphabet: { [key: string]: string } 
> }
> ```
>
> **Returns**
>
> Instance of the Text Cleaner class.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.