SourCherry Help Centre
HomeWorkflowsWorkflow Builder

Workflow Action - Custom Code




TABLE OF CONTENTS

What is Custom Code?


Custom Code is a powerful tool that will allow users to create custom logic they want to achieve and are not available currently. This provides flexibility and control beyond the pre-built actions, enabling users to automate complex tasks and integrate with various services not natively supported. This is a Premium Action.



How it works

1. Add Action



2. Programming Language


3. Property to be included in code




4. Code Editor



5. Enhanced console support


This feature captures and logs all console.log outputs from user code, allowing user to debug and monitor the code more effectively.



6. External HTTP Request






7. Format Code


8. Test your Code





9. Check Input Values in Execution logs





10. Return a response directly from their custom code.


Key Benefits:


Custom Code AI


Overview:

Writing custom code in workflows just got smarter, faster, and easier—thanks to AI! We’re thrilled to introduce Code with AI (Beta), enabling users to generate custom code snippets with just a simple description.

Previous Behaviour:

  • Previously, creating custom code within workflows required users to write JavaScript code from scratch, which could be time-consuming and required programming expertise.
  • Manually map input properties from previous workflow steps to use within the code.
  • Test and debug code manually before implementation.
  • This process demanded a significant investment of time and technical skill.

What’s New?

  • Now we have AI-Assisted Code Generation. With Code with AI, the process is streamlined:
  • AI-Powered Code Generation – Describe the desired functionality in plain language, and AI will generate JavaScript code for you.
  • Automated Property Integration – AI intelligently incorporates relevant input properties based on your description.
  • One-Click Implementation – Quickly review and insert AI-generated code into your workflow.
  • Regenerate if Needed – Not happy with the first result? Click Generate again for a fresh version.
Pro Tip: 
Be as specific as possible in your prompt for the best results!

How to Use It?

  • Select: Choose Custom Code action in your workflow.


  • Activate AI: Click "Build with AI" to open the AI assistant.

  • Describe: Input your desired functionality (e.g., "I have an API that returns a date in MM-DD-YYYY format. Can you help me convert it to YYYY-MM-DD.").
  • Generate: Click Generate and let AI craft the code for you.

image

  • Regenerate - Want to make any changes in the Code, mention the changes in the text box and click on "Regenerate"

image

  • Implement: Review the output and click Use Code to insert it into your workflow.

image

Use Cases

  • Data Formatting – Automatically format phone numbers or dates to match your preferred style.
  • API Integration – Generate code to connect with external services via HTTP requests.
  • Mathematical Calculations – Compute interest rates, discount percentages, or other formulas dynamically.
  • String Manipulation – Extract key details from text, such as email addresses from subject lines.
  • Conditional Logic – Implement custom decision-making processes, like routing leads based on specific criteria.





Points to Remember