• Сообщество
  • Блог
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаЭкспертыПодберите специалиста для разработки и развития вашего проекта на Medusa
КейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Меч Moscow
Комплексная e-commerce платформа на Medusa для московского fashion-бренда

Меч Moscow · Fashion

Нужна помощь в разработке плагина интеграции для Medusa?

Написать намНайти плагины

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
Bloomreach logo

Bloomreach

Отправляйте уведомления и отслеживайте вовлечённость

Нужна доработка этого плагина?

Связаться с нами
npm install @igorppbr/medusa-v2-bloomreach
Категория
Аналитика
Создано
Igor Ludgero Miura
Версия
1.0.0
Последнее обновление
6 месяцев назад
Ежемесячные загрузки
0
Звезды на Github
0
npmNPMGitHubGithub

Bloomreach Engagement Integration for Medusa v2

API Documentation | Bloomreach Website

Introduction

This module integrates Bloomreach (Exponea) as a notification and analytics provider for Medusa v2. It enables you to send transactional emails and SMS messages through the Bloomreach platform, as well as track customer events and behavior for powerful engagement and marketing automation.

With this plugin, you can:

  • Send transactional emails using Bloomreach email templates or custom content.
  • Send transactional SMS messages using Bloomreach SMS templates or raw text.
  • Track customer events and behavior for analytics and personalization.
  • Personalize notifications with dynamic data and customer information.
  • Monitor notification delivery and engagement through Bloomreach analytics.
  • Manage campaigns and templates directly in the Bloomreach dashboard.

Compatibility

This module/plugin is compatible with versions >= 2.4.0 of .

Prerequisites

Before using this integration, you need:

  1. A Bloomreach (Exponea) account - Sign up at Bloomreach
  2. API credentials - You'll need:
    • API Key ID - Found in your Bloomreach project settings
    • API Secret - Found in your Bloomreach project settings
    • Project ID - Your Bloomreach project identifier
    • Integration ID - The ID of your email/SMS service provider integration

Getting Your Bloomreach Credentials

  1. Log in to Bloomreach at https://app.exponea.com/
  2. Navigate to Project Settings → Access Management → API
  3. Create a new API key (or use an existing one):
    • Assign permissions: Campaigns > Transactional Email API, Campaigns > Transactional SMS API, and Events > Set
    • Note down your Key ID and Secret
  4. Find your Project ID:
    • Available in the URL when logged into your project
    • Format:
  5. Get your Integration ID:
    • Go to Project Settings → Channels → Email/SMS
    • Select your email or SMS integration
    • Copy the Integration ID from the URL or settings page

For more details, see the Bloomreach Authentication Documentation.

Installation

  1. Install the package
npm install @igorppbr/medusa-v2-bloomreach-notification
  1. Add the module to your
1import { Modules } from "@medusajs/framework/utils"
2
3export default defineConfig({
4 // ... other config
5 modules: [
6 {
7 resolve: "@medusajs/medusa/notification",
8 options: {
9 providers: [
10 // default provider
11 {
12 resolve: "@medusajs/medusa/notification-local",
13 id: "local",
14 options: {
15 name: "Local Notification Provider",
16 channels: ["feed"]
17 }
18 },
19 {
20 resolve: "@igorppbr/medusa-v2-bloomreach/providers/notifications",
21 id: "bloomreach-notification",
22 options: {
23 channels: ["email", "sms"], // Specify the channels you want to support
24 notifications: {
25 key_id: process.env.BLOOMREACH_API_KEY_ID,
26 secret: process.env.BLOOMREACH_API_SECRET,
27 project_id: process.env.BLOOMREACH_PROJECT_ID,
28 integration_id: process.env.BLOOMREACH_INTEGRATION_ID,
29 from_email: "noreply@yourdomain.com",
30 from_name: "Your Company Name",
31 from_sms: "+1234567890", // Required if using SMS channel
32 language: "en", // Optional: default language for templates
33 transfer_identity: "enabled", // Optional: 'enabled', 'disabled', or 'first_click'
34 template_mappings: { // Optional: map Medusa template names to Bloomreach template IDs
35 "order-confirmation": "60758e2d18883e1048b817a8",
36 "order-shipped": "60758e2d18883e1048b817a9"
37 },
38 campaign_mappings: { // Optional: map template names to campaign names
39 "order-confirmation": "Order Confirmation Campaign",
40 "order-shipped": "Order Shipped Campaign"
41 }
42 }
43 }
44 }
45 ]
46 }
47 },
48 {
49 resolve: "@medusajs/medusa/analytics",
50 options: {
51 providers: [
52 {
53 resolve: "@igorppbr/medusa-v2-bloomreach/providers/analytics",
54 id: "bloomreach-analytics",
55 options: {
56 notifications: {
57 key_id: process.env.BLOOMREACH_API_KEY_ID,
58 secret: process.env.BLOOMREACH_API_SECRET,
59 project_id: process.env.BLOOMREACH_PROJECT_ID
60 }
61 }
62 }
63 ]
64 }
65 }
66 ],
67 plugins: [
68 {
69 resolve: "@igorppbr/medusa-v2-bloomreach",
70 options: {},
71 },
72 ]
73})

Note: Adding the plugin is required for Medusa to load the event subscribers that handle notifications and analytics tracking.

  1. Add environment variables to your file
1BLOOMREACH_API_KEY_ID=your_api_key_id
2BLOOMREACH_API_SECRET=your_api_secret
3BLOOMREACH_PROJECT_ID=your_project_id
4BLOOMREACH_INTEGRATION_ID=your_integration_id

Important: Never commit your API credentials to version control. Always use environment variables.

Configuration Options

OptionTypeRequiredDescription
stringYesYour Bloomreach API Key ID
stringYesYour Bloomreach API Secret
stringYesYour Bloomreach Project ID
stringYesYour email/SMS integration ID
stringYesDefault sender email address
stringYesDefault sender name for emails
stringConditionalRequired if using SMS channel - sender phone number
stringNoDefault language code (e.g., "en", "es")
stringNoLink tracking behavior: "enabled", "disabled", or "first_click"
objectNoMap Medusa template names to Bloomreach template IDs
objectNoMap template names to campaign names

Usage

Tracking Customer Events (Analytics)

Track customer behavior and events for analytics and personalization:

1import { Modules } from "@medusajs/framework/utils"
2
3// In a workflow, subscriber, or API route
4const analyticsModuleService = container.resolve(Modules.ANALYTICS)
5
6await analyticsModuleService.track({
7 event: "product_viewed",
8 actor_id: "customer123",
9 properties: {
10 product_id: "prod_abc",
11 product_name: "Amazing Widget",
12 price: 99.99,
13 category: "electronics"
14 }
15})

Example: Tracking Order Events

Create a workflow to track order events:

1// src/workflows/track-order-placed.ts
2import { createWorkflow, createStep, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
3import { Modules } from "@medusajs/framework/utils"
4import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
5
6type WorkflowInput = {
7 order_id: string
8}
9
10type StepInput = {
11 order: any
12}
13
14const trackOrderPlacedStep = createStep(
15 "track-order-placed-step",
16 async ({ order }: StepInput, { container }) => {
17 const analyticsModuleService = container.resolve(Modules.ANALYTICS)
18
19 await analyticsModuleService.track({
20 event: "order_placed",
21 actor_id: order.customer_id,
22 properties: {
23 order_id: order.id,
24 order_number: order.display_id,
25 total: order.total,
26 currency: order.currency_code,
27 items: order.items.map((item) => ({
28 variant_id: item.variant_id,
29 product_id: item.product_id,
30 quantity: item.quantity,
31 price: item.unit_price
32 }))
33 }
34 })
35 }
36)
37
38export const trackOrderPlacedWorkflow = createWorkflow(
39 "track-order-placed-workflow",
40 ({ order_id }: WorkflowInput) => {
41 const { data: orders } = useQueryGraphStep({
42 entity: "order",
43 fields: ["*", "customer.*", "items.*"],
44 filters: { id: order_id }
45 })
46
47 trackOrderPlacedStep({ order: orders[0] })
48
49 return new WorkflowResponse(void 0)
50 }
51)

Then create a subscriber to execute the workflow:

1// src/subscribers/order-placed-analytics.ts
2import { SubscriberArgs, type SubscriberConfig } from "@medusajs/medusa"
3import { trackOrderPlacedWorkflow } from "../workflows/track-order-placed"
4
5export default async function orderPlacedAnalyticsHandler({
6 event: { data },
7 container,
8}: SubscriberArgs<{ id: string }>) {
9 await trackOrderPlacedWorkflow(container).run({
10 input: { order_id: data.id }
11 })
12}
13
14export const config: SubscriberConfig = {
15 event: "order.placed",
16}

Sending Email Notifications

Once configured, you can send email notifications using the Notification Module:

1import { Modules } from "@medusajs/framework/utils"
2
3// In a workflow, subscriber, or API route
4const notificationModuleService = container.resolve(Modules.NOTIFICATION)
5
6await notificationModuleService.createNotifications({
7 to: "customer@example.com",
8 channel: "email",
9 template: "order-confirmation",
10 data: {
11 order_number: "12345",
12 customer_name: "John Doe",
13 order_total: "$99.99"
14 }
15})

Sending SMS Notifications

1import { Modules } from "@medusajs/framework/utils"
2
3const notificationModuleService = container.resolve(Modules.NOTIFICATION)
4
5await notificationModuleService.createNotifications({
6 to: "+1234567890",
7 channel: "sms",
8 template: "order-shipped",
9 data: {
10 order_number: "12345",
11 tracking_number: "ABC123XYZ"
12 }
13})

Example: Order Confirmation Subscriber

Create a subscriber to send order confirmation emails:

1// src/subscribers/order-placed.ts
2import { Modules } from "@medusajs/framework/utils"
3import { SubscriberArgs, type SubscriberConfig } from "@medusajs/medusa"
4import { trackOrderPlacedWorkflow } from "../workflows/track-order-placed"
5
6export default async function orderPlacedHandler({
7 event: { data },
8 container,
9}: SubscriberArgs<{ id: string }>) {
10 // Notifications
11 try {
12 const notificationModuleService = container.resolve(Modules.NOTIFICATION)
13 const query = container.resolve("query")
14
15 // Get order details
16 const { data: [order] } = await query.graph({
17 entity: "order",
18 fields: ["*", "customer.*", "items.*"],
19 filters: { id: data.id }
20 })
21
22 // Send email notification
23 await notificationModuleService.createNotifications({
24 to: order.customer.email,
25 channel: "email",
26 template: "order-confirmation",
27 data: {
28 customer_name: `${order.customer.first_name} ${order.customer.last_name}`,
29 order_number: order.display_id,
30 order_total: order.total,
31 items: order.items
32 }
33 })
34 } catch (error) {
35 console.error("[Bloomreach] Error sending order notification:", error)
36 }
37
38 // Track analytics
39 try {
40 await trackOrderPlacedWorkflow(container).run({
41 input: { order_id: data.id }
42 })
43 } catch (error) {
44 console.error("[Bloomreach] Error tracking order analytics:", error)
45 }
46}
47
48export const config: SubscriberConfig = {
49 event: "order.placed",
50}

Template Setup in Bloomreach

  1. Log in to Bloomreach and navigate to Campaigns → Email/SMS Templates
  2. Create a new template or use an existing one
  3. Note the Template ID from the URL or template settings
  4. Add personalization variables in your template using Jinja syntax:
    1Hello {{ first_name }},
    2
    3Your order #{{ order_number }} has been confirmed!
    4Total: {{ order_total }}
  5. Map the template in your using

Features

Analytics Features

  • ✅ Track custom events and user behavior
  • ✅ Customer journey tracking
  • ✅ Event properties and metadata
  • ✅ Real-time event processing
  • ✅ Integration with Bloomreach Engagement

Email Features

  • ✅ Template-based emails with personalization
  • ✅ Custom sender name and address
  • ✅ Multi-language support
  • ✅ Link tracking and analytics
  • ✅ Campaign management

SMS Features

  • ✅ Template-based SMS with personalization
  • ✅ Raw text SMS messages
  • ✅ Multi-language support
  • ✅ Configurable message parts (1-8)
  • ✅ Campaign tracking

Troubleshooting

Common Issues

Error: "API key is required in the provider's options"

  • Make sure all required environment variables are set in your file
  • Verify that your correctly references the environment variables

Error: "From SMS is required in the provider's options to send SMS notifications"

  • Add the option to your configuration if you're using the SMS channel

Email/SMS not being sent

  • Check that your Bloomreach API credentials have the correct permissions
  • Verify that your Integration ID is correct
  • Check the Medusa logs for detailed error messages
  • Ensure your templates exist in Bloomreach and template IDs are correct

Template not found

  • Verify the template ID in your configuration
  • Check that the template exists and is published in Bloomreach

API Reference

Bloomreach SDK Functions

This package includes a Bloomreach SDK with the following functions:

Sends a transactional email through Bloomreach.

1const messageId = await sendTransactionalEmail(
2 key_id,
3 secret,
4 project_id,
5 integration_id,
6 template_id,
7 campaign_name,
8 {
9 email: "customer@example.com",
10 customer_ids: { registered: "user123" },
11 language: "en"
12 },
13 { firstName: "John", orderTotal: "99.99" },
14 sender_address,
15 sender_name,
16 transfer_identity
17)

Sends a transactional SMS through Bloomreach.

1const messageId = await sendTransactionalSms(
2 key_id,
3 secret,
4 project_id,
5 campaign_name,
6 {
7 template_id: "template789",
8 params: { order_number: "12345" }
9 },
10 {
11 phone: "+1234567890",
12 customer_ids: { registered: "user123" },
13 language: "en"
14 },
15 integration_id
16)

Tracks a customer event in Bloomreach.

1await addEvent(
2 key_id,
3 secret,
4 project_id,
5 { registered: "user@example.com" },
6 "purchase",
7 {
8 total_price: 149.99,
9 voucher_code: "SAVE20",
10 product_ids: ["prod1", "prod2"],
11 currency: "USD"
12 },
13 Math.floor(Date.now() / 1000) // Optional timestamp in seconds
14)

Contributing

We welcome contributions to this project! If you have suggestions, improvements, or bug fixes, please follow these steps:

  1. Fork the Repository
    Create a personal copy of the repository by forking it on GitHub.

  2. Create a New Branch
    Create a new branch for your changes:

    git checkout -b my-feature-branch
  3. Make Your Changes
    Implement your changes in the codebase.

  4. Test Your Changes
    Ensure that your changes work as expected and do not break existing functionality.

  5. Submit a Pull Request
    Push your changes to your forked repository and submit a pull request to the main repository.

Support / Contact

If you need help or have questions about the Bloomreach Engagement Integration, please reach out to us:

  • Email: igorlmiura@gmail.com
  • GitHub Issues: Submit an issue

License

This project is licensed under the MIT License.


Additional Resources

  • Bloomreach Documentation
  • Bloomreach API Reference
  • Medusa Documentation
  • Medusa Notification Module Guide
  • Medusa Analytics Module Guide

Еще в этой категории

Посмотреть все
Аналитика
Google Analytics logo

Google Analytics

От Variable Vic

Отслеживайте e-commerce события заказов и корзины

Загрузка данных
npm
Аналитика
K

Klaviyo

От Oak-digital

Medusa v2 plugin for Klaviyo event tracking and subscriptions.

Загрузка данных
npm

Еще от этого автора

Посмотреть все
Другое
Google Cloud Storage logo

Google Cloud Storage

От Igor Ludgero Miura

Сохраняйте загружаемые файлы через Google Cloud Storage

Загрузка данных
GitHubnpm
Доставка
FedEx logo

FedEx

От Igor Ludgero Miura

Автоматизируйте доставку через FedEx

Загрузка данных
GitHubnpm