Omniconnect Use Cases

You can accomplish the following possible use cases using Omniconnect and other 3rd party platforms.

Integrate With New Platforms

  • Integrate with Leads Generation platforms such us TikTok Leads or Typeform.
  • Integrate with Customer Support platforms such as Kustomer to bring support ticket creation and update events.
  • Integrate with Booking/Reservation platforms such as OpenTable.

Create Custom Flows

  • Create custom transformations that are aligned with your needs.

Replace Your Middleware

  • Save additional costs and complexity of maintaining multiple platforms as transformation can be done inside Bloomreach.

Example Transformation Function

Have a look at this transformation function for integrating with Typeform as an example.

/**
 * Params to be set to allow customization
 * @param {Array<string>} idQuestions - List of question ids where id is stored to use for customer identification
 * @param {string} idKey - Field id where id is stored
 */
const idQuestions = ["OyreMH40gpaO"];
const idKey = "registered";

/**
 * Handler is the entry point for the function that enables the transformation of the data.
 * @param {object} data - The input data
 * @returns {Array<object>} - Array of transformed events
 */
function handler(data) {
    const response = [];
    const { form_response: formResponse } = data;
    const timestamp = getTimestamp(formResponse.submitted_at);
    const idValue = getIdValue(formResponse.answers);
    

    const customerIds = {
        [idKey]: idValue
    };

    response.push(returnEvent(getEventProperties(data, "submission"), customerIds, timestamp));

    formResponse.definition.fields.slice(0, 50).forEach((field, index) => {
        const answer = processAnswer(formResponse.answers[index]);
        const properties = {
            ...getEventProperties(data, "answer"),
            question: field.title,
            question_id: field.id,
            question_type: field.type,
            question_index: index,
            answer_type: formResponse.answers[index].type,
            answer
        };
        response.push(returnEvent(properties, customerIds, timestamp));
    });

    return response;
}

/**
 * Extracts id from the form response answers
 * @param {Array<object>} answers - The answers from the form response
 * @returns {string | undefined} - The id or undefined if not found
 */
function getIdValue(answers) {
    const idAnswer = answers.find(obj => idQuestions.includes(obj.field.id));
    return idAnswer?.email || answers.find(obj => obj.type === 'email')?.email;
}

/**
 * Process the answer based on its type.
 * @param {object} answer - The answer object
 * @returns {*} - Processed answer
 */
function processAnswer(answer) {
    switch (answer.type) {
        case 'date':
            return getMiddayUtcTimestamp(answer.date);
        case 'choice':
            return answer.choice.label;
        case 'choices':
            return answer.choices.labels;
        default:
            return answer[answer.type];
    }
}

/**
 * Get the properties for an event.
 * @param {object} data - The input data
 * @param {string} action - The action type
 * @returns {object} - Event properties
 */
function getEventProperties(data, action) {
    const { form_response: formResponse } = data;
    return {
        action,
        integration_name: INTEGRATION_NAME,
        integration_id: INTEGRATION_ID,
        survey_name: formResponse.definition.title,
        survey_id: formResponse.form_id,
        token: formResponse.token,
        landed_at: getTimestamp(formResponse.landed_at)
    };
}

/**
 * Construct an event.
 * @param {object} properties - Event properties
 * @param {object} customerIds - Customer IDs
 * @param {number} timestamp - Event timestamp
 * @returns {object} - The event object
 */
function returnEvent(properties, customerIds, timestamp) {
    return {
        name: "customers/events",
        data: {
            customer_ids: customerIds,
            event_type: "survey",
            timestamp,
            properties
        }
    };
}

/**
 * Convert a string date to a timestamp.
 * @param {string} stringDate - The string representation of the date
 * @returns {number} - The timestamp
 */
function getTimestamp(stringDate) {
    const date = new Date(stringDate);
    return Math.floor(date.getTime() / 1000);
}

/**
 * Convert a string date to a midday UTC timestamp.
 * @param {string} dateString - The string representation of the date
 * @returns {number} - The midday UTC timestamp
 */
function getMiddayUtcTimestamp(dateString) {
    const date = new Date(dateString);
    date.setUTCHours(12, 0, 0, 0);
    return Math.floor(date.getTime() / 1000);
}