Custom code step

The Custom Code Step in Strivacity's Journey builder empowers developers to insert Node.js scripts directly into their authentication, registration, and other customer journeys. This step is particularly useful when you need to perform custom operations that exceed the scope of predefined steps, such as integrating with external APIs, processing complex data transformations, or implementing advanced logic. It offers many of the same capabilities as our Lifecycle Event Hook iterative development environment (IDE), including support for NPM dependencies, code snippets, try-out buttons, debugging tools, and access to detailed debugging logs.

Capabilities

  • Executing Node.js scripts: Run custom code to handle tasks such as data processing, API calls, or logic evaluations within the customer journey.
  • Integrating with third-party data sources: Connect to external services or databases, retrieve data, and use it to influence the customer journey in real-time.
  • Manipulating and transforming data: Perform operations like string manipulation, data mapping, and complex transformations to tailor data to your requirements.
  • Mapping third-party data to local data: Capture data from external sources and map it to native claims or local variables in Strivacity.
  • Setting local variables and native claims: Dynamically modify journey context by setting or updating local variables and native claims based on the output of your custom code.
  • IDE features: Utilize NPM dependencies, code snippets, a try-out button for real-time testing, debugging tools, and access to detailed debugging logs, similar to the capabilities offered by the Lifecycle Event Hook IDE.

Sample Use Cases

  • Data Enrichment: Enhance customer data during registration by integrating with external services (e.g., a CRM system) to gather additional information and map it to the Strivacity customer account.
  • Conditional Logic: Implement advanced logic that requires complex calculations or checks against third-party systems, directing the flow of the journey based on the results.
  • API Integration: Authenticate customers or fetch additional customer data from third-party services during the journey, especially when the data is not stored within Strivacity.
  • Custom Business Logic: Execute custom rules or processes that dictate the journey flow, such as assigning customers to specific groups based on dynamic criteria evaluated in the script.

Configuration:

To configure the Custom Code Step in the Strivacity Journey Builder:

  1. Access the Journey Builder:
    1. Log into the Strivacity Admin Console and navigate to the Journey Builder in the main navigation
  2. Add the Custom Code Step:
    1. Add the "Custom Code Step" from the available steps panel into the desired location within your journey workflow.
  3. Configure the Script:
    1. Click on the Custom Code Step to open its configuration panel.
    2. Enter your Node.js script directly into the code editor. You can include NPM dependencies by specifying them at the top of your script.
    3. Utilize the provided context objects (e.g., claims, session, variables) to interact with journey data and modify the flow based on your script's output.
  4. Use IDE Features:
    1. Make use of the available code snippets to speed up development.
    2. Test your code in real time using the try-out button.
    3. Debug your script using the built-in debugging tools and review debugging logs to troubleshoot issues.
  5. Define Outputs:
    1. If your script produces output that influences subsequent steps, ensure you define and map the necessary local variables or native claims.
  6. Save and Test:
    1. Save the journey and conduct thorough testing to verify that your custom code performs as expected within the journey.
  7. Deployment:
    1. Once testing is complete, deploy the journey by incorporating it into a live workflow. The Custom Code Step will execute as part of the customer journey according to the logic defined in your script.

For additional information on how to leverage similar functionalities within Lifecycle event hooks, refer to the Lifecycle event hooks documentation.