Here you will learn a few ways you can redact PII from your data before you send it to Dimension

PII Redaction via Redact-PII NPM Library

If you are using redact-pii NPM for integration, and you wish to remove personally identifiable information from the text, please see the steps below.

Install & Initialize Redact-PII

First, add Redact-PII to your project:

npm install redact-pii
const { Redactor } = require('redact-pii');
const redactor = new Redactor();

Redact PII from Your Data

Use Redact-PII to clean text data. The library can remove names, email addresses, phone numbers, social security numbers, and other identifiable information. It works by using predefined and customizable patterns to identify and redact sensitive information:

function redactText(text) {
  return redactor.redact(text);
}

Integrate with Dimension

Ensure data sent to Dimension is PII-free by applying the redaction:

const cleanedText = redactText(userMessage);
// Now, send `cleanedText` to Dimension

PII Redaction via Dimension Lab NPM library

If you are using the Dimension Labs NPM for integration, and you wish to remove personally identifiable information from the text, you may provide a callback to assist in the process when you include the dimensionlabs NPM library.

Install dimensionlabs via NPM

npm install --save dimensionlabs

Include Dimension

Change the inclusion of Dimension from:

const dimension = require('dimensionlabs')(process.env.DIMENSION_API_KEY).facebook;

to:

const redact = {
  // a callback that provides you the text to redact for fields that we recommend for redaction
  redactAsync: async (text) => {
    const returnValue = // integraiton with a redaction library to redact the text
    return returnValue
  }
}

const dimension = require('dimensionlabs')(
  process.env.DIMENSION_API_KEY, 
  {redact: redact}
).facebook;

const { AsyncRedactor } = require('redact-pii')
const redactor = new AsyncRedactor()
const redact = {
  // a callback that provides you the text to redact for fields that we recommend for redaction
  redactAsync: async (text) => {
    return await redactor.redactAsync(text)
  }
}

const dimension = require('dimensionlabs')(process.env.DIMENSION_API_KEY, {redact: redact}).facebook;

The example above is for Facebook bots, and enables you an easy integration point to centrally integrate with a redaction library that suits your companies redaction goals. make sure to use the appropriate platform call when invoking the Dimension Labs npm library.

Should you require further customization or additional fields within the payload to be redacted another callback can be configured to modify the entire object before sending to Dimension Labs.

const redact = {
  // a callback that provides you a copy of the object about to be sent for modification
  redactObjectAsync: async (obj) => {
    // ... the object is a copy modify it using your redaction library
    return obj
  }
}

const dimension = require('dimensionlabs')(process.env.DIMENSION_API_KEY, {redact: redact}).facebook;

const { AsyncRedactor } = require('redact-pii')
const redactor = new AsyncRedactor()
const redact = {
  // a callback that provides you a copy of the object about to be sent for modification
  redactObjectAsync: async (obj) => {
    obj.text =  await redactor.redactAsync(obj.text)
    return obj
  }
}

const dimension = require('dimensionlabs')(process.env.DIMENSION_API_KEY, {redact: redact}).facebook;

⚠️

Platform specific payloads can be difficult to catch all variations

if you are going to use redactObjectAsync(...)be sure to make modifications defensively. Our experience here at Dimension Labs is that there is a lot of variation within each platform including as they deploy new versions to enhance capabilities. A property that was there in one payload may not be there in another or might even disappear in the future.

📘

Note

if you configure both callbacks then redactAsync(...)will be executed first and the output will be provided to redactObjectAsync(...) before being sent.