omnichannel-chat-sdk
CLAUDE.md67 starsChanged 6 months agoMITView on GitHub
This workspace may contain up to 6 related repositories. Not all teams have all repos working together. Always be aware of which repository you're in when making changes. This repo already has comprehensive Copilot instructions. Read them ALL before any task: CRITICAL: All existing Copilot instructions apply to Claude Code as well. Follow them strictly. From copilot-instructions.md - MANDATORY: This repo follows a strict "ASK FIRST" protocol: 1. Understand the request and read relevant code 2. Propose specific changes with…
- Deletes or force-pushes
- Installs packages
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
32 rules. About 0 are common, 23 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈23
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 33
CRITICAL: All existing Copilot instructions apply to Claude Code as well.
- Distinctive: line 46
Implement: only after approval
- Distinctive: line 104
Canonical process: Follow docs/RELEASING.md
- Very specific: line 107
Prohibited: Do not run npm publish manually and do not use workflow dispatch for an official release
- Very specific: line 113
Critical: Follow docs/copilot/CODING_GUIDELINES.md for all TypeScript code.
- Very specific: line 118
Avoid
anytype: - Use proper type definitions - Distinctive: line 120
Explicit return types: - Always declare function return types
- Distinctive: line 205
Purpose: Test against real MessagingRuntime APIs (test environment)
- Distinctive: line 209
Test both happy path and error scenarios
- Distinctive: line 210
Verify telemetry calls (startScenario, completeScenario, failScenario)
- Very specific: line 211
Test cross-platform compatibility (Node.js, Browser environments)
- Distinctive: line 228
Use semantic versioning: major version for breaking changes
- Very specific: line 239
Code standards: Follow docs/copilot/CODING_GUIDELINES.md
- Distinctive: line 241
Testing: All tests must pass, add tests for new functionality
- Distinctive: line 242
Documentation: Update JSDoc comments, README.md if APIs change
- Distinctive: line 244
CHANGELOG: Update CHANGELOG.md under [Unreleased] section:
- Very specific: line 254
Run vsts-npm-auth -config .npmrc to refresh Azure DevOps authentication
- Distinctive: line 255
Check internal npm feed access (requires permissions)
- Very specific: line 259
Check Node version: node --version (must match engines in package.json)
- Distinctive: line 262
Check if MessagingRuntime test environment is available
- Distinctive: line 263
Verify test configuration in jest.config files
- Very specific: line 264
Use npm run test:debug for debugging
- Very specific: line 267
Ensure you're authenticated to npm registry: npm whoami
- Distinctive: line 268
Check package version doesn't already exist
- Distinctive: line 269
Verify no uncommitted changes: git status
- Distinctive: line 293
Create tracking work item
- Distinctive: line 297
Add new API (backwards-compatible)
- Distinctive: line 299
Update CHANGELOG.md with migration guide
- Distinctive: line 300
After 2 releases, remove old API (major version bump)
- Distinctive: line 303
Update README.md with new API examples
- Distinctive: line 304
Add migration guide to CHANGELOG.md
- Distinctive: line 305
Update TypeScript type definitions
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
omnichannel-chat-sdk - Claude Code Instructions
Repository Ecosystem
This workspace may contain up to 6 related repositories. Not all teams have all repos working together. Always be aware of which repository you're in when making changes.
| Repository | Type | Purpose | Typical Location |
| CRM.Omnichannel | Monorepo (Backend) | 20+ microservices for Omnichannel platform | <workspace-root>/CRM.Omnichannel/ |
| ConversationControl | Frontend (Agent UI) | Agent experience and conversation management UI | <workspace-root>/CRM.OmniChannel.ConversationControl/ |
| LiveChatWidget | Frontend (Customer) | Customer-facing chat widget | <workspace-root>/CRM.OmniChannel.LiveChatWidget/ |
| omnichannel-chat-sdk | Public SDK | TypeScript SDK for chat integration | <workspace-root>/omnichannel-chat-sdk/ |
| omnichannel-chat-widget | Public Components | React component library | <workspace-root>/omnichannel-chat-widget/ |
| omnichannel-amsclient | Shared Library | File upload/download client | <workspace-root>/omnichannel-amsclient/ |
Quick Context
- Purpose: Public SDK for building custom chat experiences with Dynamics 365 Omnichannel
- Type: TypeScript Library (npm package)
- Tech Stack: TypeScript, Rollup, Jest, Playwright
- Distribution: npm registry (@microsoft/omnichannel-chat-sdk)
- Consumers: CRM.OmniChannel.LiveChatWidget, omnichannel-chat-widget, external customers
Memory Bank & Existing Instructions (Read First)
This repo already has comprehensive Copilot instructions. Read them ALL before any task:
- .github/copilot-instructions.md - ASK FIRST protocol, PR guidelines, coding standards
- docs/copilot/CODING_GUIDELINES.md - Essential patterns and requirements
- docs/copilot/PROMPT_TEMPLATES.md - Copilot prompt templates
CRITICAL: All existing Copilot instructions apply to Claude Code as well. Follow them strictly.
Authorization Protocol (ASK FIRST)
From copilot-instructions.md - MANDATORY:
This repo follows a strict "ASK FIRST" protocol:
- Understand the request and read relevant code
- Propose specific changes with file paths and code snippets
- Explain impact on consumers (LiveChatWidget, chat-widget, external customers)
- Wait for explicit approval ("yes", "proceed", "go")
- Implement only after approval
NEVER modify code without explicit user authorization.
Architecture Overview
What is omnichannel-chat-sdk?
This is the official TypeScript SDK for integrating Omnichannel chat into custom applications. It provides a strongly-typed API for chat operations (start chat, send message, end chat, file attachments) and abstracts the MessagingRuntime REST APIs.
Key Features:
- Promise-based async API
- TypeScript type definitions
- Comprehensive error handling (ChatSDKExceptionDetails)
- Telemetry integration (startScenario → completeScenario/failScenario)
- Cross-platform support (Browser, Node.js, React Native)
Integration:
- Backend: Consumes MessagingRuntime REST APIs (
/api/messaging/v1/*) - ACS: Integrates with Azure Communication Services for chat threading
- Consumers: LiveChatWidget, chat-widget, external customers (public npm)
Build & Test Workflow
Prerequisites
- Node.js (version in package.json engines)
- npm package manager
- Authentication:
vsts-npm-authfor Azure DevOps npm registry (internal dependencies)
Setup
cd omnichannel-chat-sdk
# Authenticate with Azure DevOps npm registry
vsts-npm-auth -config .npmrc
# Install dependencies
npm installCommon Commands
Build:
- Build SDK:
npm run build:tsc- TypeScript compilation - Bundle:
npm run build- Rollup bundling (ESM, CJS, UMD) - Watch mode:
npm run watch- Incremental development
Test:
- Unit tests:
npm test- Jest tests - E2E tests:
npm run test:e2e- Playwright integration tests - Coverage:
npm run coverage- Test coverage report - Lint:
npm run lint- ESLint validation
Release:
- Canonical process: Follow docs/RELEASING.md
- Official release: Merge a release PR, then push
v<version>on that exact merge commit - Automation: The tag publishes the package to npm and creates the GitHub Release with changelog notes and the exact npm tarball
- Prohibited: Do not run
npm publishmanually and do not use workflow dispatch for an official release
Coding Standards
Critical: Follow docs/copilot/CODING_GUIDELINES.md for all TypeScript code.
Key Conventions from Copilot Instructions
TypeScript Best Practices:
- Avoid
anytype - Use proper type definitions - Strict TypeScript - Enable strict mode in tsconfig.json
- Explicit return types - Always declare function return types
- Async/await preferred - Over .then() chains
- Cross-platform compatibility - Code must work in Browser, Node.js, React Native
Telemetry Pattern (MANDATORY):
// ✅ CORRECT - startScenario → completeScenario/failScenario pattern
async sendMessage(message: string): Promise<void> {
this.telemetry.startScenario('SendMessage');
try {
const response = await this.httpClient.post('/api/messaging/v1/messages/send', {
conversationId: this.conversationId,
content: message
});
this.telemetry.completeScenario('SendMessage');
} catch (error) {
this.telemetry.failScenario('SendMessage', error);
throw new ChatSDKError('Failed to send message', error);
}
}Error Handling (MANDATORY):
// Use ChatSDKExceptionDetails structure
export interface ChatSDKExceptionDetails {
message: string;
errorCode: string;
innerError?: Error;
context?: Record<string, unknown>;
}
// Example usage
throw new ChatSDKError({
message: 'Failed to start chat',
errorCode: 'START_CHAT_FAILED',
innerError: error,
context: { chatConfig }
});Method Structure:
// Standard async method pattern
export async function methodName(
param1: Type1,
param2: Type2,
optionalConfig?: OptionalType
): Promise<ReturnType> {
// 1. Validate inputs
if (!param1) {
throw new ChatSDKError({ message: 'param1 is required', errorCode: 'INVALID_INPUT' });
}
// 2. Start telemetry scenario
this.telemetry.startScenario('MethodName');
try {
// 3. Business logic
const result = await this.performOperation(param1, param2);
// 4. Complete telemetry
this.telemetry.completeScenario('MethodName');
return result;
} catch (error) {
// 5. Fail telemetry and rethrow
this.telemetry.failScenario('MethodName', error);
throw new ChatSDKError({ message: 'Operation failed', errorCode: 'OPERATION_FAILED', innerError: error });
}
}Testing Strategy
Unit Tests (Jest):
- Location:
__tests__/directory - Run:
npm test - Coverage: Maintain >80% coverage for business logic
E2E Tests (Playwright):
- Location:
playwright/directory - Run:
npm run test:e2e - Purpose: Test against real MessagingRuntime APIs (test environment)
Test Best Practices:
- Mock external dependencies (HTTP client, telemetry)
- Test both happy path and error scenarios
- Verify telemetry calls (startScenario, completeScenario, failScenario)
- Test cross-platform compatibility (Node.js, Browser environments)
Integration with Other Repos
This SDK integrates with:
- CRM.Omnichannel (Backend): MessagingRuntime REST APIs for chat operations
- Azure Communication Services: Chat thread management (abstracted by backend)
Consumed by:
- CRM.OmniChannel.LiveChatWidget (npm dependency) - Customer chat widget
- omnichannel-chat-widget (npm peer dependency) - Shared React components
- External customers (public npm) - Custom chat integrations
When changing public APIs:
- This is a public contract - breaking changes affect external customers
- Use semantic versioning: major version for breaking changes
- Coordinate with LiveChatWidget and chat-widget teams
- Provide migration guide in CHANGELOG.md
- Announce breaking changes in release notes
Pull Request Guidelines
From copilot-instructions.md:
- Code standards: Follow docs/copilot/CODING_GUIDELINES.md
- Commit messages: Conventional commit format (feat:, fix:, chore:, etc.)
- Testing: All tests must pass, add tests for new functionality
- Documentation: Update JSDoc comments, README.md if APIs change
- Authorization: Get explicit approval before implementing
- CHANGELOG: Update CHANGELOG.md under [Unreleased] section:
- Fixed: for bugs
- Changed: for improvements or modified functionality
- Added: for new features or components
Common Issues & Troubleshooting
Authentication Issues:
- Run
vsts-npm-auth -config .npmrcto refresh Azure DevOps authentication - Check internal npm feed access (requires permissions)
Build Issues:
- Clear node_modules:
rm -rf node_modules && npm install - Check Node version:
node --version(must match engines in package.json)
Test Failures:
- Check if MessagingRuntime test environment is available
- Verify test configuration in jest.config files
- Use
npm run test:debugfor debugging
Publish Issues:
- Ensure you're authenticated to npm registry:
npm whoami - Check package version doesn't already exist
- Verify no uncommitted changes:
git status
Documentation
- README.md - SDK usage, API reference, examples
- CHANGELOG.md - Release history, breaking changes
- docs/copilot/ - Copilot coding guidelines and templates
- docs/ - Additional documentation
Breaking Change Protocol
Before making breaking changes to public APIs:
- Identify impact:
- LiveChatWidget dependency (check package.json version)
- chat-widget dependency (peer dependency)
- External customers (check npm download stats)
- Coordination:
- Notify LiveChatWidget and chat-widget teams
- Create tracking work item
- Plan migration timeline (minimum 2 release cycles for deprecation)
- Implementation:
- Add new API (backwards-compatible)
- Mark old API as
@deprecatedin JSDoc - Update CHANGELOG.md with migration guide
- After 2 releases, remove old API (major version bump)
- Documentation:
- Update README.md with new API examples
- Add migration guide to CHANGELOG.md
- Update TypeScript type definitions
Summary: This is a public SDK with strict ASK FIRST protocol. Follow existing Copilot instructions, maintain telemetry patterns, use ChatSDKExceptionDetails for errors, and coordinate breaking changes with consumers.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

