Text Formatter
The Text Formatter component is a utility tool designed to clean and reshape text before it is used by other parts of your automation workflow. Think of it as a digital editor that instantly fixes typos, standardizes capitalization, and removes unwanted characters from your data.
In the Nappai automation system, this component is ideal for preparing raw text data for analysis, database storage, or further AI processing. It ensures that your text is consistent and clean, which helps other components work more accurately.
How it Works
When you connect a text message to this component, Nappai applies a series of transformations in a specific order. You can think of this process like a factory assembly line where the text moves through different stations to get cleaned up.
- Trimming: First, the component checks if you want to remove extra empty spaces from the beginning and end of the text.
- Accent Removal: It can then strip away accents and diacritics (like changing “café” to “cafe” or “niño” to “nino”), making the text easier to search or match.
- Case Conversion: You can choose to make the entire text lowercase, uppercase, or capitalized (First Letter Of Each Word).
- Space Replacement: If enabled, all standard spaces can be swapped for a different character (like a dash
-or underscore_), which is useful for creating URL-friendly strings or specific file names. - Custom Replacement: Finally, it can search for specific characters you define and replace them with others you choose (e.g., replacing all commas with periods).
All these steps happen automatically when the workflow runs, transforming the input into a clean, structured output ready for the next step.
Connection & Credentials
This component does not require any external API keys or credentials. It processes data locally within the Nappai environment.
Inputs
Mapping Mode
This component has a special mode called “Mapping Mode”. When you enable this mode using the toggle switch, an additional input called “Mapping Data” is activated, and each input field offers you three different ways to provide data:
- Fixed: You type the value directly into the field.
- Mapped: You connect the output of another component to use its result as the value.
- Javascript: You write Javascript code to dynamically calculate the value.
This flexibility allows you to create more dynamic and connected workflows.
Input Fields
The following fields are available to configure this component. Each field may be visible in different operations:
- Message: The text or message you want to format. This is the starting point for your data.
- Case Conversion: A dropdown menu that lets you choose how the text should look in terms of capitalization. Options include “None”, “lowercase”, “UPPERCASE”, and “Capitalize”.
- Remove Accents: A toggle switch. When turned on, it removes accents and diacritics from letters (e.g., changing “é” to “e”).
- Trim Whitespace: A toggle switch. When turned on, it removes extra spaces from the very beginning and end of the text.
- Replace Spaces: A toggle switch. When turned on, it allows you to replace standard spaces with another character.
- Replace Spaces With: The character you want to use instead of a space (e.g.,
-or_). Only visible when “Replace Spaces” is enabled. - Replace Characters: A toggle switch. When turned on, it allows you to perform custom find-and-replace operations.
- Number of Replacements: A number field (1-5) that determines how many custom replacement pairs you will set up. Only visible when “Replace Characters” is enabled.
- Find: The character or text you want to search for. Only visible when “Replace Characters” is enabled.
- Replace with: The text you want to put in place of the found text. Leave empty if you want to delete the found text. Only visible when “Replace Characters” is enabled.
Outputs
Output Data Example (JSON)
The component produces a single output containing the transformed text. json { “formatted_message”: { “text”: “hello-world-nino”, “metadata”: {} } }
Note: The actual output structure in Nappai will be a Message object, but the core value users care about is the text field above.
Connectivity
This component is typically placed early in a data processing workflow.
- Input Connections: Connect the output of data extraction components (like Web Scrapers, File Readers, or API Fetchers) into the Message input.
- Output Connections: Connect the Formatted Message output to components that require clean text, such as:
- Database Writers: To ensure data consistency before saving.
- AI Assistants (LLMs): To provide cleaner prompts or context.
- Text Splitters: To ensure consistent delimiters for splitting text.
Logical sense: By cleaning data before sending it to an AI or database, you reduce errors and improve performance.
Usage Example
Scenario: You are automating the process of creating SEO-friendly URL slugs from blog post titles.
- Input: Connect a component that outputs a title like
" The Café & The Boy's Guide ". - Configuration:
- Set Case Conversion to
"lowercase". - Toggle Remove Accents ON.
- Toggle Trim Whitespace ON.
- Toggle Replace Spaces ON and set Replace Spaces With to
"-".
- Set Case Conversion to
- Result: The output will be
"the-cafe-the-boys-guide", which is perfect for a URL.
Tips and Best Practices
- Order Matters: The transformations happen in a specific sequence (Trim -> Accents -> Case -> Spaces -> Custom). If you need to replace spaces before removing accents, ensure your workflow logic accounts for this order, or apply transformations in separate steps.
- Performance: For very large datasets, using the “Remove Accents” and “Trim Whitespace” features is highly efficient as they are lightweight operations.
- Dynamic Fields: Remember that the “Find” and “Replace with” fields only appear when you enable “Replace Characters” and select a count. Don’t look for them when the component is in default settings.
Security Considerations
- Input Validation: Ensure that the text you are feeding into this component comes from trusted sources. While this component formats text, it does not inherently sanitize for malicious code injection (like SQL injection). Always pair this with appropriate security filters in later stages of your workflow if handling user-generated content.
- Data Privacy: Be mindful that this component processes text in memory. Avoid sending sensitive personal data (PII) through formatting nodes if your workflow involves third-party integrations later on.