Unify Automations
Logo
Code By UnifyApps

Code By UnifyApps

Logo

4 mins READ

Overview

Code by UnifyApps is a powerful automation component that allows users to execute custom code as part of their automation workflows. It serves as a flexible action step that supports multiple programming languages including Groovy, Java, JavaScript, Python, and custom snippets, enabling developers to implement complex logic and integrations that might not be feasible with standard pre-built actions.

Frame 4733 (1).png
Frame 4733 (1).png

Actions supported

Code by UnifyApps enables the execution of the following actions:

ActionDescriptionCommon Use Cases
Execute groovy codeExecutes Groovy code to perform custom actionsData transformation, complex string manipulation, integration with Java libraries
Execute javascriptExecutes JavaScript to perform custom actionsWeb API integrations, JSON manipulation, frontend interactions
Execute python scriptExecutes Python script to perform custom actionsData analysis, machine learning, scientific computing, complex calculations
Execute method from classpathInvokes a method from the specified classpathAccessing existing business logic, reusing enterprise methods, legacy system integration
Execute Java codeExecutes Java code to perform custom actionsEnterprise integrations, high-performance operations, using Java libraries
Execute custom code snippetsExecutes pre-written snippets of code to perform custom actionsReusing common logic patterns, standardized operations, team-shared functions
Execute playwright scriptExecutes playwright scripts to perform browser actions and returns the resultWeb scraping, UI testing, form automation, screenshot capture

Libraries Supported

Code by UnifyApps provides access to numerous libraries across different programming languages to help you build powerful automations.

Python Libraries

The following Python libraries are available on the platform:

LangChain Ecosystem

LibraryDescription
langchainFramework for developing applications powered by language models
langchain-openaiOpenAI integration for LangChain
langchain-experimentalExperimental features for LangChain
langchain-communityCommunity-contributed LangChain integrations
langchain-huggingfaceHugging Face integration for LangChain

Data Science & Machine Learning

LibraryDescription
pandasData analysis and manipulation tool
numpyScientific computing with Python
torchMachine learning framework
transformersNLP for PyTorch and TensorFlow
scikit-learnMachine learning for Python
boto3AWS SDK for Python
sentence_transformersSentence, text and image embeddings
spacyNatural language processing
nltkNatural language toolkit

Security & Document Processing

LibraryDescription
presidio-analyzerContext aware PII identification
presidio-anonymizerAnonymize detected PII entities
pymupdfPDF document processing
ebooklibE-book handling library
bcryptPassword hashing
msoffcrypto-toolMS Office document encryption
cryptographyCryptographic recipes and primitives

Utilities & Helpers

LibraryDescription
openpyxlRead/write Excel files
requestsHTTP library
pytzWorld timezone definitions
unstructuredExtract data from documents
unstructured[pdf,ppt,docx]Document format extensions
markdownifyConvert HTML to Markdown
beautifulsoup4Screen-scraping library
lxmlXML and HTML processing
xlrdExtract data from Excel files
fakerGenerate fake data

Framework Support

LibraryDescription
aiofilesFile support for asyncio
aiobotocoreAsync client for AWS services
pydanticData validation using Python type hints
pydantic-mongoPydantic and MongoDB integration
parsoPython parser
cohereAccess to Cohere's language models

Java & Groovy Libraries

The platform supports all commonly used Java, Javascript and Groovy libraries. Users can raise a request to support@unifyapps.com for queries regarding any library.

Use case

Let's demonstrate how to properly set up a code using Code by UnifyApps. In this example, our automation is triggered via a new mail in our Outlook account. We will capture the subject of the email and extract certain components from it using Regex.

  • Start off by defining the input parameters for the code block. In our scenario, we will just need to take in the  subject from the upstream automation.

  • Since we are expecting to extract certain elements from the subject, go ahead and define your necessary output parameters.

    Thumbnail

    Note

    Ensure that you are using appropriate casing since these input/output parameters will be used in your code as well. Good practice is to either use snake casing or camel casing for the keys of the variables.

    Frame 4734 (1).png
    Frame 4734 (1).png

  • Next, we can write the code as required in the editor. We can also expand the editor for easier use.

  • Remember to return the desired output statements using a return statement.

    Group 155 (1).png
    Group 155 (1).png
    Thumbnail

    Note

    It is essential to return the output of the code so as to be able to use it in the downstream automation. You have to map the variables in your code against the output parameters defined and then write a return statement.

    Frame 4736.png
    Frame 4736.png

  • We also have the ability to run the code in an asynchronous mode, i.e., that the workflow won’t wait for the code to finish and simply move on to the next steps.

  • Finally, you have to map the input parameters with their respective data pills and the code is then ready to execute.

FAQs

Can I use external libraries in my code?

Yes, but only libraries that are pre-installed in the UnifyApps environment. Check the list of available libraries. If you wish to enquire about any additional library please contact us at support@unifyapps.com.

How do I pass data between my code and the rest of the workflow?

Data is passed through the input and output mappings. Your code receives the input object and should return a value that becomes available to subsequent steps.

My code works locally but fails in UnifyApps. What could be wrong?

Common issues include missing dependencies, environment differences, timeout limitations, or permissions restrictions. Check logs for specific error messages.

My code is returning an output, but it is passing onto downstream automation. What could be wrong?

Most common issue faced by users is the improper mapping of output variables in the return statement. Please find the appropriate return statement above.  Additionally, make sure that the keys used in the output parameters matches exactly with the ones in the return statement. It is case sensitive.