JSON Response Attribute mapping in API Node


Introduction

The JSON Handler Node is a powerful new addition to the Journey Builder Canvas in the Bot Studio platform. It allows bot designers to effortlessly extract information from simple to complex JSON objects without requiring coding expertise. This feature simplifies handling JSON responses from APIs or channel messages, making the platform more accessible, especially for non-technical users.


Key Features

  1. Intuitive JSON Parsing
    • Provides a user-friendly interface to parse JSON responses and map attributes to variables.
  2. Flexible Variable Selection
    • Select from Local, Global, and System variables containing JSON responses.
    • Encrypted JSON variables are excluded from selection to ensure security.
  3. Sample JSON Input & Editor
    • Input a sample JSON to visualize and map data.
    • Use the Open Editor to modify or map elements within the JSON.
    • Split-panel editor with code view (left) and formatted JSON with mapping capabilities (right).
  4. Hover-to-Map Feature
    • Hover over keys and values in the formatted JSON to quickly map them to variables.
  5. Transform & Validation
    • Transform Button reformats JSON for easier viewing.
    • Real-time error handling for invalid JSON inputs.
  6. Mapping Capabilities
    • Create up to 10 mappings per node.
    • Support for nested JSON structures and arrays.
    • Enforce values as stringified objects using the Enforce String option.
  7. Data Persistence
    • Sample JSON and mappings are saved with the journey upon Save or Deploy actions.
    • Runtime validation ensures correct data types; failures will prevent updates to the destination variable.

Key Benefits

  1. Simplified JSON Handling
    • Eliminates the need for custom code, allowing non-technical users to manage JSON data effortlessly.
  2. Enhanced Flexibility
    • Supports a wide range of JSON structures, from simple key-value pairs to deeply nested objects.
  3. Increased Efficiency
    • Reduces the time and effort required to handle JSON responses within journeys.
  4. Error-Free Data Mapping
    • Built-in validation ensures that only correct mappings are applied, reducing runtime errors.

How to Use

  1. Add the JSON Handler Node
    • Navigate to Action Nodes in Journey Builder and select JSON Handler.
  2. Select JSON Variable
    • Choose the variable containing the JSON response from the dropdown (Local, Global, or System).
  3. Input Sample JSON
    • Enter a sample JSON to visualize the structure.
    • Click on the Open Editor to make changes or set up mappings.
  4. Map JSON Attributes
    • Use the hover functionality in the right panel to map JSON keys/values to variables.
    • Review mappings in the Path to Attribute -> Set to Variable section.
  5. Save and Deploy
    • Click Save to store your mappings and JSON structure.
    • Deploy the journey to apply the JSON Handler Node in live scenarios.

Use Cases

  1. API Response Handling
    • Scenario: Extract user data (e.g., name, email) from API responses.
    • Benefit: Simplifies parsing API responses without custom code.

  2. Channel Message Parsing
    • Scenario: Process structured JSON messages received from messaging platforms.
    • Benefit: Quickly extract and utilize key message details in the journey.

  3. Nested Data Extraction
    • Scenario: Handle complex nested JSON objects from third-party integrations.
    • Benefit: Supports deep JSON structures, making complex data extraction seamless.

Error Handling

  1. Invalid JSON Inputs
    • Real-time error messages appear in the editor if JSON is invalid.
  2. Mapping Errors
    • Validation errors are triggered if mappings are incorrectly set.
    • Runtime validation ensures data type compatibility; failures prevent incorrect data storage.