feat: Slack platform + Claude-powered chat support widget
- Add Slack as customer-facing messaging platform (client, 4 MCP tools, dashboard card) - Add /api/chat endpoint powered by Claude Haiku with SquareMCP system prompt - Add embeddable chat-widget.js injected into all 3 sites (docs, app, www) - Add ANTHROPIC_API_KEY, serve product/ as static files - Update Platform type to include slack Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
49
src/chat.ts
Normal file
49
src/chat.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import Anthropic from '@anthropic-ai/sdk';
|
||||
|
||||
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
|
||||
|
||||
const SYSTEM_PROMPT = `You are a friendly and knowledgeable support assistant for SquareMCP — an AI Social Media Gateway that lets AI agents (Claude, ChatGPT, Codex CLI, etc.) post to social platforms via the Model Context Protocol (MCP).
|
||||
|
||||
What SquareMCP does:
|
||||
- Connects AI coding assistants to social platforms: LinkedIn, TikTok, WhatsApp, Instagram, Twitter/X, Facebook, Telegram, Discord, Slack, and Email
|
||||
- Works with any MCP-compatible client: Claude Desktop, Claude Code, Cursor, Windsurf, opencode, Codex CLI
|
||||
- Provides a multi-tenant SaaS platform where each customer securely stores their own platform credentials
|
||||
- Offers a simple dashboard to connect platforms, view usage, and manage webhooks
|
||||
- Plans: Free (100 calls/month), Pro, Business
|
||||
|
||||
How it works:
|
||||
1. Customer signs up at the SquareMCP dashboard
|
||||
2. Connects their social accounts (bot tokens, API keys)
|
||||
3. Adds the SquareMCP MCP server to their AI client config
|
||||
4. Their AI agent can now send messages, post content, read analytics — on any connected platform
|
||||
|
||||
Common questions:
|
||||
- Pricing: Free tier available, paid plans for higher usage
|
||||
- Supported platforms: LinkedIn, TikTok, WhatsApp Business, Instagram, Twitter/X, Facebook, Telegram, Discord, Slack, Email
|
||||
- No coding required to use the dashboard; coding experience helps to get the most from MCP tool calls
|
||||
- Webhooks: customers can receive real-time events when messages arrive
|
||||
- Security: credentials are encrypted at rest, each customer's data is isolated
|
||||
|
||||
Keep answers concise (2-4 sentences max). If you don't know something, say so and suggest emailing support@squaremcp.com. Never make up features or pricing. Speak in a warm, direct tone.`;
|
||||
|
||||
export interface ChatMessage {
|
||||
role: 'user' | 'assistant';
|
||||
content: string;
|
||||
}
|
||||
|
||||
export async function handleChat(messages: ChatMessage[]): Promise<string> {
|
||||
if (!process.env.ANTHROPIC_API_KEY) {
|
||||
throw new Error('ANTHROPIC_API_KEY not configured');
|
||||
}
|
||||
|
||||
const response = await client.messages.create({
|
||||
model: 'claude-haiku-4-5-20251001',
|
||||
max_tokens: 512,
|
||||
system: SYSTEM_PROMPT,
|
||||
messages: messages.map(m => ({ role: m.role, content: m.content })),
|
||||
});
|
||||
|
||||
const block = response.content[0];
|
||||
if (block.type !== 'text') throw new Error('Unexpected response type');
|
||||
return block.text;
|
||||
}
|
||||
Reference in New Issue
Block a user