• 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
8
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: v311
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

To add a new formatter, simply add it to the formatters object in index.ts:

const formatters = { // ... existing formatters "new-attribute-type": (value) => value.someProperty, "complex-type": async (value) => { // Async formatter example const result = await someAsyncOperation(value); return result.toString(); }, };

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"

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'"

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.