Prerequisites
1
Node.js
Install Node.js 18 or later. We recommend using nvm for managing Node.js versions.
2
Package manager
Choose your preferred package manager:
3
Git
Ensure Git is installed:
Project Setup
Creating a New Project
1
Initialize your project
2
Install dependencies
3
Configure TypeScript
Create a
tsconfig.json file:tsconfig.json
4
Add scripts to package.json
package.json
Directory Structure
Organize your project:Environment Configuration
Create .env File
.env
Add .gitignore
.gitignore
Load Environment Variables
Install and configure dotenv:src/index.ts
Basic Application Setup
Create API Client
src/api/client.ts
Main Application Entry
src/index.ts
Testing Setup
Install Testing Dependencies
Configure Jest
jest.config.js
Write Tests
tests/api.test.ts
Development Workflow
Running in Development
Running Tests
Web Application Setup
For building web applications:Next.js Setup
Vite Setup
Debugging
VS Code Configuration
Create.vscode/launch.json:
.vscode/launch.json
Enable Debug Logging
src/index.ts
Linting and Formatting
ESLint Setup
.eslintrc.js
Prettier Setup
.prettierrc
package.json:
Common Development Tasks
Creating App Passwords
For development, create an app password at:Testing with Local PDS
Run a local PDS for development:.env:
Best Practices
1
Use TypeScript
TypeScript provides type safety and better IDE support.
2
Version control your code
Always use Git and commit regularly.
3
Never commit secrets
Use
.gitignore to exclude .env files and other sensitive data.4
Write tests
Test your code to catch bugs early and ensure reliability.
5
Use environment-specific configs
Create separate configs for development, staging, and production.
Troubleshooting
Common Issues
Module not found errors
Module not found errors
Ensure dependencies are installed:
TypeScript compilation errors
TypeScript compilation errors
Check your
tsconfig.json and ensure all dependencies are properly typed:Authentication failures
Authentication failures
Verify your credentials in
.env:- Check that your handle is correct
- Ensure you’re using an app password, not your main password
- Verify the service URL is correct
CORS errors in browser
CORS errors in browser
For browser applications, ensure you’re using OAuth, not credential-based auth.
Next Steps
Using the API
Learn how to use the Agent API
OAuth Authentication
Set up OAuth for production
Rich Text
Work with mentions and links
Quickstart
Build your first app quickly