Signal Adapter for Idiomark
A Idiomark (Personality Capture Protocol) adapter for extracting personality signals from Signal Desktop's local SQLite database.
Overview
Signal does not provide a public API, so this adapter reads directly from the local SQLite database used by Signal Desktop. This allows for comprehensive personality analysis based on:
- Message content and timing patterns
- Communication style and message length
- Reactions and response patterns
- Quote/reply behavior
- Group vs. direct message dynamics
- Edit behavior and message refinement
- Emoji usage patterns
Prerequisites
Signal Desktop Installation
You must have Signal Desktop installed and synced with your Signal account. The adapter reads from the local database file created by Signal Desktop.
Database Location
Signal Desktop stores its SQLite database at the following locations:
| Platform | Path |
|---|---|
| Windows | %AppData%\Signal\sql\db.sqlite |
| macOS | ~/Library/Application Support/Signal/sql/db.sqlite |
| Linux | ~/.config/Signal/sql/db/db.sqlite |
Installation
npm install @idiomark/adapter-signal
# or
pnpm add @idiomark/adapter-signal
# or
yarn add @idiomark/adapter-signal
Dependencies
This adapter uses better-sqlite3 for database access, which requires native compilation. You may need to install build tools:
# Windows
npm install -g windows-build-tools
# macOS
xcode-select --install
# Linux
sudo apt-get install build-essential
Usage
Basic Usage
import { SignalAdapter, findSignalDatabasePath } from '@idiomark/adapter-signal'
// Find the default Signal database path
const dbPath = findSignalDatabasePath()
if (!dbPath) {
console.error('Signal database not found. Please ensure Signal Desktop is installed.')
process.exit(1)
}
// Create adapter instance
const adapter = new SignalAdapter({
databasePath: dbPath,
phoneNumber: '+1234567890' // Optional: your phone number
})
// Authenticate (validates database file)
const authenticated = await adapter.authenticate()
if (!authenticated) {
console.error('Failed to authenticate with Signal database')
process.exit(1)
}
// Fetch messages and conversations
const content = await adapter.fetchData({
includeDirectMessages: true,
includeGroupMessages: true,
startDate: new Date('2024-01-01'),
endDate: new Date(),
maxMessagesPerConversation: 100
})
// Normalize content for Idiomark analysis
const normalized = content.map(c => adapter.normalize(c))
// Extract personality signals
const signals = adapter.extractPersonalitySignals(content)
console.log('Personality signals:', signals)
// Get structured output
const output = await adapter.getStructuredOutput({
startDate: new Date('2024-01-01'),
endDate: new Date()
})
console.log('Sample size:', output.metadata.sampleSize)
console.log('Messages:', output.metadata.statistics.messages)
// Clean up
await adapter.dispose()
Using the Convenience Function
import { fetchSignalMessages, findSignalDatabasePath } from '@idiomark/adapter-signal'
const dbPath = findSignalDatabasePath()
if (dbPath) {
const output = await fetchSignalMessages(dbPath, {
includeDirectMessages: true,
includeGroupMessages: false,
startDate: new Date('2024-01-01'),
endDate: new Date(),
minMessageLength: 10
})
console.log('Raw content:', output.rawContent)
console.log('Statistics:', output.metadata.statistics)
}
Getting Database Information
import { getSignalDatabaseInfo, findSignalDatabasePath } from '@idiomark/adapter-signal'
// Auto-detect database
const dbPath = findSignalDatabasePath()
// Get database info
const info = getSignalDatabaseInfo(dbPath)
console.log('Database path:', info.path)
console.log('Database exists:', info.exists)
console.log('Database size:', info.size, 'bytes')
console.log('Message count:', info.messageCount)
console.log('Conversation count:', info.conversationCount)
Fetch Options
interface SignalFetchOptions {
// Include direct messages (1-on-1 conversations)
includeDirectMessages?: boolean // default: true
// Include group conversations
includeGroupMessages?: boolean // default: true
// Include story replies
includeStories?: boolean // default: false
// Include reactions in the data
includeReactions?: boolean // default: true
// Include attachment metadata
includeAttachments?: boolean // default: true
// Include quote/reply information
includeQuotes?: boolean // default: true
// Include message edits
includeEdits?: boolean // default: true
// Maximum messages per conversation
maxMessagesPerConversation?: number // default: 1000
// Filter by conversation IDs
conversationIds?: string[]
// Filter by date range
startDate?: Date
endDate?: Date
// Minimum message length (to filter out noise)
minMessageLength?: number // default: 1
// Include expired/disappeared messages
includeExpiredMessages?: boolean // default: false
}
Output Structure
interface SignalAdapterOutput {
rawContent: string[] // Array of message texts
metadata: {
sampleSize: number // Total content items
timeframe: {
from: string // ISO date string
to: string // ISO date string
}
sources: string[] // ['signal']
statistics: {
messages: {
totalMessages: number
incomingMessages: number
outgoingMessages: number
editedMessages: number
messagesWithReactions: number
messagesWithAttachments: number
messagesWithQuotes: number
directMessages: number
groupMessages: number
averageMessageLength: number
mostActiveConversations: Array<{
conversationId: string
name?: string
messageCount: number
}>
hourlyDistribution: Array<{
hour: number
count: number
}>
dailyDistribution: Array<{
day: number
count: number
}>
}
conversations: {
totalConversations: number
directConversations: number
groupConversations: number
activeConversations: number
archivedConversations: number
pinnedConversations: number
totalUnreadMessages: number
}
}
}
}
Personality Signals Extracted
The adapter extracts the following personality signals:
Voice
- Emoji Usage: Frequency and types of emojis used
- Common Phrases: Repeated 2-3 word phrases
- Message Patterns: Length, timing, and structure
Communication Style
- Message Count: Total messages sent/received
- Reply Behavior: Frequency of quotes/replies
- Edit Frequency: How often messages are refined
- Reaction Patterns: Giving and receiving reactions
Interests & Social Dynamics
- Topics: Common discussion themes
- Contacts: Most frequently contacted people
- Activity Patterns: When the person is most active
Error Handling
import {
SignalAdapterError,
SignalDatabaseError,
SignalAuthError,
SignalConfigError
} from '@idiomark/adapter-signal'
try {
const adapter = new SignalAdapter({ databasePath: '/path/to/db.sqlite' })
await adapter.authenticate()
} catch (error) {
if (error instanceof SignalAuthError) {
console.error('Authentication failed:', error.message)
} else if (error instanceof SignalDatabaseError) {
console.error('Database error:', error.message, error.details)
} else if (error instanceof SignalConfigError) {
console.error('Configuration error:', error.message)
} else {
console.error('Unknown error:', error)
}
}
PlatformAdapter Implementation
This adapter implements the full PlatformAdapter interface:
- authenticate(): Validates the database file exists and is accessible
- fetchData(options): Retrieves messages, conversations, and profile data
- normalize(raw): Converts raw Signal content to Idiomark format
- healthCheck(): Checks database connectivity
- reset(): Clears cache and reopens connection
- dispose(): Closes database connection
- getMetrics(): Returns adapter statistics
Privacy Considerations
Important: This adapter reads personal communication data from your local Signal database. Be aware of:
- Sensitive Content: Messages may contain personal, private, or sensitive information
- Contact Information: Phone numbers and names of your contacts are accessible
- Media Metadata: Information about shared media is included
- Database Lock: Signal Desktop may need to be closed while reading
Recommendations
- Only analyze data you have permission to access
- Consider the ethical implications of personality analysis
- Store generated Idiomark files securely
- Don't share raw message content without consent
Troubleshooting
Database Not Found
Error: Signal database not found at /path/to/db.sqlite
Solution: Ensure Signal Desktop is installed and has been used at least once. Check that the database path is correct for your platform.
Database Locked
Error: Database is locked
Solution: Close Signal Desktop before running the adapter, or make a copy of the database file to read from.
Native Module Build Errors
Error: Cannot find module 'better-sqlite3'
Solution: Rebuild native dependencies:
npm rebuild better-sqlite3
No Messages Found
If no messages are returned, check:
- The database file is from the correct Signal Desktop installation
- Your Signal account has messages (new installations may be empty)
- The date range filters include actual message dates
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please read the contributing guidelines before submitting PRs.
Related Packages
- @idiomark/core - Core Idiomark protocol types and utilities
- @idiomark/cli - CLI tool for Idiomark extraction
Support
For issues, questions, or contributions, please visit the Idiomark repository.