emailr_
Todos os artigos
usecase·10 min

Email B2B: Padrões de notificações Enterprise

b2benterprisepatterns

Email B2B difere fundamentalmente do email para consumidor. Clientes Enterprise esperam confiabilidade, informações detalhadas e integração com seus fluxos de trabalho. Veja como projetar sistemas de notificações B2B.

Características de email B2B

Email para Enterprise precisa lidar com:

  • Múltiplos destinatários por organização
  • Notificações baseadas em função
  • Requisitos de auditoria e conformidade
  • Integração com ferramentas Enterprise
  • Expectativas mais altas de entregabilidade

Notificações no nível da organização

Alertas de equipe

interface TeamAlert {
  organization: {
    id: string;
    name: string;
  };
  alert: {
    type: 'security' | 'billing' | 'usage' | 'system';
    severity: 'info' | 'warning' | 'critical';
    title: string;
    details: string;
  };
  recipients: TeamMember[];
}


async function sendTeamAlert(alert: TeamAlert) {
  // Filter recipients by role and preferences
  const recipients = alert.recipients.filter(member => 
    shouldReceiveAlert(member, alert.alert.type, alert.alert.severity)
  );

  for (const recipient of recipients) {
    await sendEmail({
      to: recipient.email,
      subject: `[${alert.alert.severity.toUpperCase()}] ${alert.alert.title}`,
      template: 'team-alert',
      data: {
        organization: alert.organization,
        alert: alert.alert,
        recipient,
        actionUrl: getAlertActionUrl(alert)
      },
      headers: {
        'X-Priority': alert.alert.severity === 'critical' ? '1' : '3'
      }
    });
  }
}

Notificações para administradores

interface AdminNotification {
  type: 'user_added' | 'user_removed' | 'role_changed' | 'settings_changed';
  actor: { name: string; email: string };
  target?: { name: string; email: string };
  details: Record<string, any>;
  timestamp: Date;
}

// Notify all admins of security-relevant changes
async function notifyAdmins(org: Organization, notification: AdminNotification) {
  const admins = await getOrgAdmins(org.id);
  
  for (const admin of admins) {
    await sendEmail({
      to: admin.email,
      subject: `[${org.name}] ${formatNotificationType(notification.type)}`,
      template: 'admin-notification',
      data: {
        org,
        notification,
        auditLogUrl: `${baseUrl}/admin/audit-log`
      }
    });
  }
}

Notificações baseadas em função

Entrega respeitando permissões

interface RoleBasedEmail {
  organization: Organization;
  emailType: string;
  data: Record<string, any>;
}

async function sendRoleBasedEmail(config: RoleBasedEmail) {
  const roleConfig = {
    'billing.invoice': ['owner', 'billing_admin'],
    'security.alert': ['owner', 'security_admin', 'admin'],
    'usage.warning': ['owner', 'admin'],
    'user.joined': ['owner', 'admin', 'hr_admin'],
    'feature.announcement': ['owner', 'admin', 'user']
  };

  const allowedRoles = roleConfig[config.emailType] || ['owner'];
  const recipients = await getOrgMembersByRoles(config.organization.id, allowedRoles);

  for (const recipient of recipients) {
    await sendEmail({
      to: recipient.email,
      template: config.emailType.replace('.', '-'),
      data: {
        ...config.data,
        recipient,
        organization: config.organization
      }
    });
  }
}

Padrões de escalonamento

interface EscalationConfig {
  initialRecipients: string[];  // roles
  escalateAfter: number;        // minutes
  escalateTo: string[];         // roles
  maxEscalations: number;
}

async function sendWithEscalation(
  org: Organization,
  alert: Alert,
  config: EscalationConfig
) {
  // Send initial notification
  await sendToRoles(org, alert, config.initialRecipients);
  
  // Schedule escalation check
  await scheduleJob({
    type: 'check_escalation',
    runAt: addMinutes(new Date(), config.escalateAfter),
    data: {
      alertId: alert.id,
      orgId: org.id,
      escalationLevel: 1,
      config
    }
  });
}

async function checkEscalation(job: EscalationJob) {
  const alert = await getAlert(job.data.alertId);
  
  if (alert.acknowledged) return;
  
  if (job.data.escalationLevel < job.data.config.maxEscalations) {
    // Escalate to next level
    await sendToRoles(
      await getOrg(job.data.orgId),
      alert,
      job.data.config.escalateTo
    );
    
    // Schedule next escalation
    await scheduleJob({
      ...job,
      runAt: addMinutes(new Date(), job.data.config.escalateAfter),
      data: {
        ...job.data,
        escalationLevel: job.data.escalationLevel + 1
      }
    });
  }
}

Emails de faturamento para Enterprise

Notificações de fatura

interface InvoiceEmail {
  organization: Organization;
  invoice: {
    id: string;
    number: string;
    amount: number;
    currency: string;
    dueDate: Date;
    lineItems: LineItem[];
    pdfUrl: string;
  };
}

await sendEmail({
  to: billingContact.email,
  subject: `Invoice #${invoice.number} for ${org.name}`,
  template: 'invoice',
  data: {
    organization: org,
    invoice,
    paymentUrl: `${baseUrl}/billing/pay/${invoice.id}`,
    supportEmail: '[email protected]'
  },
  attachments: [
    {
      filename: `invoice-${invoice.number}.pdf`,
      path: invoice.pdfUrl
    }
  ]
});

Alertas de uso

const usageAlertThresholds = [
  { percent: 75, template: 'usage-warning-75' },
  { percent: 90, template: 'usage-warning-90' },
  { percent: 100, template: 'usage-limit-reached' }
];

async function checkUsageAlerts(org: Organization) {
  const usage = await getOrgUsage(org.id);
  const limit = org.plan.limits;
  const percent = (usage.current / limit.max) * 100;

  for (const threshold of usageAlertThresholds) {
    if (percent >= threshold.percent && !await hasAlertedThreshold(org.id, threshold.percent)) {
      await sendRoleBasedEmail({
        organization: org,
        emailType: 'usage.warning',
        data: {
          currentUsage: usage.current,
          limit: limit.max,
          percent,
          upgradeUrl: `${baseUrl}/billing/upgrade`
        }
      });
      
      await markThresholdAlerted(org.id, threshold.percent);
    }
  }
}

Conformidade e auditoria

Emails de auditoria

// Send audit summary to compliance team
async function sendAuditDigest(org: Organization) {
  const events = await getAuditEvents(org.id, {
    since: subDays(new Date(), 7),
    types: ['security', 'access', 'data']
  });

  const complianceContacts = await getComplianceContacts(org.id);

  for (const contact of complianceContacts) {
    await sendEmail({
      to: contact.email,
      subject: `Weekly audit digest for ${org.name}`,
      template: 'audit-digest',
      data: {
        organization: org,
        period: 'Last 7 days',
        summary: {
          totalEvents: events.length,
          byType: groupBy(events, 'type'),
          flaggedEvents: events.filter(e => e.flagged)
        },
        fullReportUrl: `${baseUrl}/admin/audit-log`
      }
    });
  }
}

Notificações de exportação de dados

// GDPR data export ready
await sendEmail({
  to: requester.email,
  subject: `Data export ready for ${org.name}`,
  template: 'data-export-ready',
  data: {
    organization: org,
    export: {
      requestedAt: exportRequest.createdAt,
      expiresAt: addDays(new Date(), 7),
      downloadUrl: exportRequest.downloadUrl,
      format: 'JSON'
    },
    securityNote: 'This link expires in 7 days. Download contains sensitive data.'
  }
});

Notificações de integração

Alertas de falha de webhook

await sendEmail({
  to: techContact.email,
  subject: `[Action Required] Webhook failures for ${org.name}`,
  template: 'webhook-failures',
  data: {
    organization: org,
    webhook: {
      url: webhook.url,
      failureCount: webhook.consecutiveFailures,
      lastError: webhook.lastError,
      lastAttempt: webhook.lastAttemptAt
    },
    action: webhook.consecutiveFailures >= 10 
      ? 'Webhook has been disabled' 
      : 'Will retry automatically',
    settingsUrl: `${baseUrl}/settings/webhooks`
  }
});

Preferências de notificações para Enterprise

interface EnterpriseNotificationPrefs {
  // Organization-level defaults
  orgDefaults: {
    securityAlerts: 'all_admins' | 'security_team' | 'owner_only';
    billingNotifications: 'billing_contact' | 'all_admins';
    usageAlerts: boolean;
    weeklyDigest: boolean;
  };
  
  // Per-user overrides
  userOverrides: {
    [userId: string]: {
      emailEnabled: boolean;
      digestFrequency: 'daily' | 'weekly' | 'never';
      alertTypes: string[];
    };
  };
}

Boas práticas

  1. Entrega baseada em função - Envie para as pessoas certas conforme suas responsabilidades
  2. Níveis claros de severidade - Deixe a urgência evidente nas linhas de assunto
  3. Conteúdo acionável - Inclua links diretos para resolver problemas
  4. Audite tudo - Registre todas as notificações para conformidade
  5. Caminhos de escalonamento - Garanta que alertas críticos cheguem a alguém
  6. Respeite preferências - Permita controle granular de notificações

Email B2B é sobre confiabilidade e confiança. Suas notificações devem ajudar as organizações a funcionar sem problemas enquanto mantêm padrões de segurança e conformidade.

e_

Escrito pela equipe emailr

Construindo infraestrutura de email para desenvolvedores

Pronto para começar a enviar?

Obtenha sua chave API e envie seu primeiro email em menos de 5 minutos. Não é necessário cartão de crédito.