| name | twinmind-local-dev-loop |
| description | Set up local development workflow with TwinMind API integration.
Use when building applications that integrate TwinMind transcription,
testing API calls locally, or developing meeting automation tools.
Trigger with phrases like "twinmind dev setup", "twinmind local development",
"twinmind API testing", "build with twinmind".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Bash(pip:*), Bash(curl:*) |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
TwinMind Local Dev Loop
Overview
Configure a productive local development environment for TwinMind API integration.
Prerequisites
- TwinMind Pro or Enterprise account (API access)
- Node.js 18+ or Python 3.10+
- API key from TwinMind dashboard
- Local development environment
Instructions
Step 1: Project Setup
mkdir twinmind-integration && cd twinmind-integration
npm init -y
npm install dotenv axios zod typescript ts-node @types/node
npx tsc --init
Step 2: Configure Environment
cat > .env << 'EOF'
TWINMIND_API_KEY=your-api-key-here
TWINMIND_API_URL=https://api.twinmind.com/v1
TWINMIND_WEBHOOK_SECRET=your-webhook-secret
NODE_ENV=development
EOF
echo ".env" >> .gitignore
echo "node_modules" >> .gitignore
Step 3: Create TwinMind Client
import axios, { AxiosInstance } from 'axios';
import { z } from 'zod';
const TranscriptSchema = z.object({
id: z.string(),
text: z.string(),
duration_seconds: z.number(),
language: z.string(),
speakers: z.array(z.object({
id: z.string(),
name: z.string().optional(),
segments: z.array(z.object({
start: z.number(),
end: z.number(),
text: z.string(),
confidence: z.number(),
})),
})),
created_at: z.string(),
});
const SummarySchema = z.object({
id: z.string(),
transcript_id: z.string(),
summary: z.string(),
: z.(z.({
: z.(),
: z.().(),
: z.().(),
})),
: z.(z.()),
});
= z.< >;
= z.< >;
{
: ;
() {
. = axios.({
: baseUrl || ,
: {
: ,
: ,
},
: ,
});
}
(): <> {
response = ..();
response. === ;
}
(: , ?: {
?: ;
?: ;
?: | ;
}): <> {
response = ..(, {
: audioUrl,
: options?. || ,
: options?. ?? ,
: options?. || ,
});
.(response.);
}
(: ): <> {
response = ..(, {
: transcriptId,
});
.(response.);
}
(: , ?: {
?: ;
?: ;
?: ;
}): <[]> {
response = ..(, {
: {
: query,
: options?. || ,
: options?.,
: options?.,
},
});
z.().(response..);
}
}
Step 4: Create Dev Runner Script
import 'dotenv/config';
import { TwinMindClient } from './twinmind/client';
async function main() {
const client = new TwinMindClient(process.env.TWINMIND_API_KEY!);
console.log('Checking TwinMind API health...');
const healthy = await client.healthCheck();
console.log(`API Status: ${healthy ? 'Healthy' : 'Unhealthy'}`);
}
main().catch(console.error);
Step 5: Configure Dev Scripts
{
"scripts": {
"dev": "ts-node src/dev.ts",
"build": "tsc",
"test": "jest",
"lint": "eslint src/**/*.ts",
"typecheck": "tsc --noEmit"
}
}
Step 6: Create Test Fixtures
export const mockTranscript = {
id: 'tr_test_123',
text: 'Welcome to the meeting. Today we discuss the project timeline.',
duration_seconds: 45,
language: 'en',
speakers: [
{
id: 'spk_1',
name: 'Host',
segments: [
{
start: 0,
end: 5.2,
text: 'Welcome to the meeting.',
confidence: 0.97,
},
{
start: 5.5,
end: 12.1,
text: 'Today we discuss the project timeline.',
confidence: 0.95,
},
],
},
],
created_at: '2025-01-15T10:00:00Z',
};
export const mockSummary = {
id: 'sum_test_456',
transcript_id: 'tr_test_123',
summary: 'Brief meeting to discuss project timeline and milestones.',
action_items: [
{
text: 'Review timeline document',
assignee: 'John',
due_date: ,
},
],
: [
,
,
],
};
Step 7: Run Development Loop
npm run dev
npm install -D nodemon
npx nodemon --exec ts-node src/dev.ts
DEBUG=twinmind:* npm run dev
Output
- Project structure with TypeScript configuration
- TwinMind client with type-safe schemas
- Environment configuration
- Development scripts
- Test fixtures for offline development
Error Handling
| Error | Cause | Solution |
|---|
| API key missing | .env not loaded | Check dotenv import |
| Connection refused | Wrong API URL | Verify TWINMIND_API_URL |
| Rate limited | Too many requests | Add delay between calls |
| Schema validation failed | API response changed | Update Zod schemas |
| Timeout | Large audio file | Increase timeout value |
Project Structure
twinmind-integration/
├── src/
│ ├── twinmind/
│ │ ├── client.ts # API client
│ │ ├── types.ts # TypeScript types
│ │ └── errors.ts # Error classes
│ ├── services/
│ │ └── meeting.ts # Business logic
│ └── dev.ts # Development entry
├── tests/
│ ├── fixtures/
│ │ └── mock-responses.ts
│ └── twinmind.test.ts
├── .env # Environment (gitignored)
├── .env.example # Template
├── package.json
└── tsconfig.json
Resources
Next Steps
Apply patterns in twinmind-sdk-patterns for production-ready code.