Companies

Managing company profiles and associations

Companies

Associate visitors with companies for B2B support scenarios.

Overview

Companies allow you to:

  • Group users by organization
  • View all conversations from a company
  • Track company-level attributes
  • Prioritize enterprise customers

Associating Users with Companies

Via Widget SDK

TransactionalSupport('identify', 'user-123', {
  name: 'John Doe',
  email: 'john@acme.com'
});
 
// Associate with a company
TransactionalSupport('company', 'company-456', {
  name: 'Acme Inc',
  plan: 'enterprise',
  size: '100-500',
  industry: 'Technology',
  website: 'https://acme.com'
});

Via API

const response = await fetch('/api/support/companies', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-api-key',
  },
  body: JSON.stringify({
    id: 'company-456', // Your internal company ID
    name: 'Acme Inc',
    attributes: {
      plan: 'enterprise',
      size: '100-500',
      industry: 'Technology',
      website: 'https://acme.com',
      mrr: 5000
    }
  }),
});

Associate Visitor with Company

const response = await fetch('/api/support/visitors/{visitorId}/company', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-api-key',
  },
  body: JSON.stringify({
    companyId: 'company-456'
  }),
});

Company Profile

View in Dashboard

  1. Navigate to Support > Companies
  2. Search for a company
  3. Click to view profile

Profile Contains

  • Company Info: Name, website, industry
  • People: All associated users
  • Conversations: All conversations from company users
  • Attributes: Custom data (plan, MRR, etc.)
  • Notes: Internal notes about the company

API Operations

Create Company

const response = await fetch('/api/support/companies', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-api-key',
  },
  body: JSON.stringify({
    id: 'company-456',
    name: 'Acme Inc',
    attributes: {
      plan: 'enterprise',
      size: '100-500',
      industry: 'Technology'
    }
  }),
});

Get Company

const response = await fetch('/api/support/companies/{companyId}', {
  headers: {
    'X-API-Key': 'your-api-key',
  },
});
 
const { data } = await response.json();

Response:

{
  data: {
    id: 'company-456',
    name: 'Acme Inc',
    website: 'https://acme.com',
    industry: 'Technology',
    size: '100-500',
    attributes: {
      plan: 'enterprise',
      mrr: 5000,
      accountManager: 'Jane Smith'
    },
    userCount: 15,
    conversationCount: 45,
    createdAt: '2024-01-01T10:00:00Z',
    updatedAt: '2024-01-15T10:00:00Z'
  }
}

List Companies

const response = await fetch('/api/support/companies', {
  headers: {
    'X-API-Key': 'your-api-key',
  },
});
 
const { data, meta } = await response.json();

Query parameters:

ParameterTypeDescription
searchstringSearch by name
industrystringFilter by industry
planstringFilter by plan attribute
pagenumberPage number
limitnumberItems per page

Update Company

const response = await fetch('/api/support/companies/{companyId}', {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-api-key',
  },
  body: JSON.stringify({
    name: 'Acme Corporation',
    attributes: {
      plan: 'enterprise-plus',
      mrr: 10000
    }
  }),
});

Delete Company

const response = await fetch('/api/support/companies/{companyId}', {
  method: 'DELETE',
  headers: {
    'X-API-Key': 'your-api-key',
  },
});

List Company Users

const response = await fetch('/api/support/companies/{companyId}/users', {
  headers: {
    'X-API-Key': 'your-api-key',
  },
});
 
const { data } = await response.json();

List Company Conversations

const response = await fetch('/api/support/companies/{companyId}/conversations', {
  headers: {
    'X-API-Key': 'your-api-key',
  },
});
 
const { data } = await response.json();

Company Attributes

Standard Attributes

AttributeTypeDescription
namestringCompany name
websitestringCompany website
industrystringIndustry category
sizestringEmployee count range

Custom Attributes

Add any custom attributes:

TransactionalSupport('company', 'company-456', {
  name: 'Acme Inc',
  // Custom attributes
  plan: 'enterprise',
  mrr: 5000,
  contractEndDate: '2025-01-01',
  accountManager: 'Jane Smith',
  healthScore: 85,
  npsScore: 9,
  lastReviewDate: '2024-06-01',
  features: ['analytics', 'api', 'sso']
});

Priority Routing

Route conversations based on company attributes:

By Plan

{
  routingRules: [
    {
      condition: { company: { plan: 'enterprise' } },
      inboxId: 'priority-inbox',
      assignTo: 'enterprise-team'
    }
  ]
}

By MRR

{
  routingRules: [
    {
      condition: { company: { mrr: { greaterThan: 1000 } } },
      inboxId: 'priority-inbox'
    }
  ]
}

Company Notes

Add internal notes about companies:

const response = await fetch('/api/support/companies/{companyId}/notes', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-api-key',
  },
  body: JSON.stringify({
    content: 'Contract renewal coming up in Q1. Schedule call with account manager.'
  }),
});

Company Analytics

Get Company Stats

const response = await fetch('/api/support/companies/{companyId}/stats', {
  headers: {
    'X-API-Key': 'your-api-key',
  },
});
 
const { data } = await response.json();

Response:

{
  data: {
    totalConversations: 45,
    openConversations: 3,
    avgResponseTime: 300, // seconds
    avgResolutionTime: 7200, // seconds
    csat: 4.2,
    topIssues: [
      { tag: 'billing', count: 10 },
      { tag: 'feature-request', count: 8 }
    ]
  }
}

Segmentation

Create company segments:

const response = await fetch('/api/support/company-segments', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'your-api-key',
  },
  body: JSON.stringify({
    name: 'Enterprise Customers',
    conditions: [
      { field: 'attributes.plan', operator: 'equals', value: 'enterprise' }
    ]
  }),
});

Syncing from CRM

Keep company data in sync with your CRM:

Webhook Integration

// In your CRM webhook handler
app.post('/webhook/crm', async (req, res) => {
  const { type, company } = req.body;
 
  if (type === 'company.updated') {
    await fetch('https://api.usetransactional.com/support/companies/' + company.id, {
      method: 'PUT',
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': process.env.TRANSACTIONAL_API_KEY,
      },
      body: JSON.stringify({
        name: company.name,
        attributes: {
          plan: company.plan,
          mrr: company.mrr,
          accountManager: company.owner.name
        }
      }),
    });
  }
 
  res.status(200).json({ received: true });
});

Next Steps