Skip to main content

Encode/Decode Component

Use the Encode/Decode component to transform data into various standard encoding formats and back again. It's essential for ensuring data integrity, compatibility with different systems, and preparing data for safe transmission.

Why this matters

Many systems, especially web APIs, require data to be in a specific format (like Base64) to be transmitted correctly. This component allows your agent to seamlessly convert data, making it compatible with a wide range of services without custom code.

What You’ll Configure

Step 1: Select an Action and Encoding Method

First, choose whether you want to Encode or Decode data. Then, select the specific encoding format to use.

SettingDescription
ActionChoose Encode to convert data into a new format, or Decode to revert it back to its original form.
EncodingSelect the specific method: hex, base64, base64url, or latin1.
Which Encoding Should I Use?
  • base64: The most common format for including binary data (like images) in text-based contexts like JSON payloads.
  • base64url: A URL-safe version of Base64, ideal for including in URL parameters without issues.
  • hex: Useful for cryptographic applications or when a human-readable binary representation is needed.

Step 2: Provide Input Data

The component has a single input field to receive the data you want to process.

InputRequired?Description
DataYesThe data to be encoded or decoded. Can be a string or binary data.

Step 3: Handle the Output Data

A single output field provides the result of the transformation.

OutputDescription
OutputThe processed data, either newly encoded or returned to its original decoded state.

Best Practices

  • Match the Action to the Data: Ensure you are using Decode on data that is actually encoded, and Encode on raw data. Applying the wrong action will result in an error or garbage output.
  • Prepare Data for APIs: Use this component to encode data right before passing it to an API Call that requires a specific format.
  • Handle Different Character Sets: Be mindful of character sets. latin1 is useful for certain legacy systems, but base64 is generally more universal for handling complex data.

Troubleshooting Tips

If your transformation fails...
  • Decoding Error: The most common issue is trying to decode a string that is not a valid representation of the selected encoding format (e.g., trying to base64 decode a regular sentence). Verify your input data is correctly formatted.
  • Incorrect Output: Double-check that you have selected the correct Encoding method. For example, base64 and base64url are similar but not identical, and decoding with the wrong one will fail.
  • Binary Data Issues: If you are encoding binary data (like an image file), ensure it is being passed correctly to the Data input field before the encoding step.

What to Try Next

  • Take the output from an Image Generator, base64 encode it, and send it as part of a JSON payload in an API Call.
  • Receive a base64url encoded token from an API response, decode it, and then use a JSON Filter to parse the resulting JSON object.
  • Use the Hash Component on a piece of data, then hex encode the resulting hash for display or storage.