• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
nbbaier

nbbaier

attio-slack-summaries

Remix of stevekrouse/attio-slack-summaries
Public
Like
attio-slack-summaries
Home
Code
9
extractors
1
formatters
3
scripts
2
services
6
shared
3
.vtignore
README.md
C
alert.ts
H
webhook.ts
Branches
4
Pull requests
Remixes
2
History
Environment variables
2
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
formatters
/
README.md
Code
/
formatters
/
README.md
Search
9/7/2025
Viewing readonly version of simplification branch: v317
View latest version
README.md

Formatters Directory

This directory contains a consolidated formatter system for different types of Attio attribute values. The formatters convert Attio API data into human-readable strings for display in Slack notifications.

Usage

Import and use the single formatter function:

import { formatAttributeValue } from "./formatters/index.ts"; const formattedValue = await formatAttributeValue(attributeValue);

How It Works

The formatter system uses a registry pattern where all formatters are defined in a single object and automatically selected based on the attribute type. This provides:

  • Type Safety: Each formatter is properly typed for its specific attribute type
  • Automatic Selection: No need to manually choose which formatter to use
  • Centralized Management: All formatters are defined in one place
  • Easy Extension: Adding new formatters requires only one line

Supported Attribute Types

The system automatically handles these Attio attribute types:

  • text - Simple text values
  • status - Status values with titles
  • select - Dropdown/select values with option titles
  • date - Date values
  • timestamp - Timestamp values
  • rating - Numeric rating values
  • checkbox - Boolean checkbox values
  • currency - Currency values with proper formatting
  • record-reference - References to other records (fetches record name)
  • actor-reference - References to users/actors (fetches actor name)

Adding New Formatters

Core Formatters (Always Available)

The system includes 10 core formatters for commonly used Attio attribute types. These are always available and don't require any setup.

Uncommon Formatters (Optional)

For the 7 additional Attio attribute types, you can easily add formatters when needed:

Option 1: Add All Uncommon Formatters

import { addUncommonFormatters } from "./formatters/uncommon.ts"; // Add all 7 uncommon formatters at once addUncommonFormatters();

Option 2: Add Specific Uncommon Formatters

import { addSpecificUncommonFormatters } from "./formatters/uncommon.ts"; // Add only the formatters you need addSpecificUncommonFormatters(["domain", "email-address", "location"]);

Option 3: Add Custom Formatters

import { addFormatters } from "./formatters/index.ts"; // Add your own custom formatters addFormatters({ "custom-type": (value) => value.customProperty, "another-type": async (value) => { const result = await someAsyncOperation(value); return result.toString(); }, });

Available Uncommon Formatters

  • domain - Domain names
  • email-address - Email addresses with parsed components
  • interaction - Interaction tracking (calls, meetings, etc.)
  • location - Address information with coordinates
  • number - Numeric values
  • personal-name - First/last name combinations
  • phone-number - Phone numbers with country codes

Examples

Basic Usage

import { formatAttributeValue } from "./formatters/index.ts"; // Text attribute const textValue = await formatAttributeValue({ attribute_type: "text", value: "Hello World", }); // Status attribute const statusValue = await formatAttributeValue({ attribute_type: "status", status: { title: "Active" }, }); // Currency attribute const currencyValue = await formatAttributeValue({ attribute_type: "currency", currency_value: 123.45, currency_code: "USD", }); // Result: "$123.45"

Using Uncommon Formatters

import { formatAttributeValue } from "./formatters/index.ts"; import { addUncommonFormatters } from "./formatters/uncommon.ts"; // First, add the uncommon formatters you need addUncommonFormatters(); // Now you can format uncommon attribute types const domainValue = await formatAttributeValue({ attribute_type: "domain", domain: "example.com", root_domain: "example.com", // ... other properties }); // Result: "example.com" const emailValue = await formatAttributeValue({ attribute_type: "email-address", email_address: "user@example.com", // ... other properties }); // Result: "user@example.com"

Error Handling

// If an unsupported attribute type is provided const result = await formatAttributeValue({ attribute_type: "unsupported-type", // ... other properties }); // Result: "Error: no formatter found for attribute type 'unsupported-type'. Use addFormatters() to add support for this type."

Architecture

The formatter system consists of:

  1. Type Definition: FormatterFunction<T> - Generic type for formatter functions
  2. Registry Object: Maps attribute types to their specific formatters
  3. Main Function: formatAttributeValue() - Public API that handles type selection and execution
  4. Type Safety: Uses TypeScript's Extract utility to ensure proper typing

This design eliminates the need for individual formatter functions and provides a clean, maintainable API.

FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.