Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(docs): add share feedback button with Slack integration
Sushmithamallesh5f1fe0c31c64
diff --git a/docs/.env.example b/docs/.env.exampleindex d9742b25f..5d41a7002 100644--- a/docs/.env.example+++ b/docs/.env.example@@ -8,3 +8,6 @@ OPENAPI_SPEC_URL=https://backend.composio.dev/api/v3/openapi.json# PostHog Analytics (optional)NEXT_PUBLIC_POSTHOG_KEY=your_posthog_project_api_keyNEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com++# Slack webhook for docs feedback (create at https://api.slack.com/apps)+SLACK_FEEDBACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx/xxx/xxxdiff --git a/docs/app/api/feedback/route.ts b/docs/app/api/feedback/route.tsnew file mode 100644index 000000000..2a39dc42f--- /dev/null+++ b/docs/app/api/feedback/route.ts@@ -0,0 +1,85 @@+import { NextRequest, NextResponse } from 'next/server';++const SLACK_WEBHOOK_URL = process.env.SLACK_FEEDBACK_WEBHOOK_URL;++const sentimentEmoji: Record<string, string> = {+ positive: 'π',+ neutral: 'π',+ negative: 'π',+};++export async function POST(request: NextRequest) {+ if (!SLACK_WEBHOOK_URL) {+ console.error('SLACK_FEEDBACK_WEBHOOK_URL is not configured');+ return NextResponse.json({ error: 'Feedback not configured' }, { status: 500 });+ }++ try {+ const { page, sentiment, message, email } = await request.json();++ if (!message?.trim()) {+ return NextResponse.json({ error: 'Message is required' }, { status: 400 });+ }++ const emoji = sentiment ? sentimentEmoji[sentiment] || '' : '';++ const slackMessage = {+ blocks: [+ {+ type: 'header',+ text: {+ type: 'plain_text',+ text: `${emoji} New Docs Feedback`,+ emoji: true,+ },+ },+ {+ type: 'section',+ fields: [+ {+ type: 'mrkdwn',+ text: `*Page:*\n<https://composio.dev${page}|${page}>`,+ },+ {+ type: 'mrkdwn',+ text: `*Sentiment:*\n${sentiment || 'Not specified'}`,+ },+ ],+ },+ {+ type: 'section',+ text: {+ type: 'mrkdwn',+ text: `*Feedback:*\n${message}`,+ },+ },+ ? [+ {+ type: 'section',+ text: {+ type: 'mrkdwn',+ text: `*Email:*\n${email}`,+ },+ },+ ]+ : []),+ ],+ };++ const response = await fetch(SLACK_WEBHOOK_URL, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify(slackMessage),+ });++ if (!response.ok) {+ throw new Error('Failed to send to Slack');+ }++ return NextResponse.json({ success: true });+ } catch (error) {+ console.error('Feedback error:', error);+ return NextResponse.json({ error: 'Failed to submit feedback' }, { status: 500 });+ }+}diff --git a/docs/components/feedback.tsx b/docs/components/feedback.tsxnew file mode 100644index 000000000..049f471b9--- /dev/null+++ b/docs/components/feedback.tsx@@ -0,0 +1,173 @@+'use client';++import { useState } from 'react';+import { MessageSquare, X, Loader2 } from 'lucide-react';++type Sentiment = 'positive' | 'neutral' | 'negative' | null;++interface FeedbackProps {+ page: string;+}++export function Feedback({ page }: FeedbackProps) {+ const [isOpen, setIsOpen] = useState(false);+ const [sentiment, setSentiment] = useState<Sentiment>(null);+ const [message, setMessage] = useState('');+ const [email, setEmail] = useState('');+ const [state, setState] = useState<'idle' | 'loading' | 'success' | 'error'>('idle');++ const handleSubmit = async (e: React.FormEvent) => {+ e.preventDefault();+ if (!message.trim()) return;++ setState('loading');++ try {+ const response = await fetch('/api/feedback', {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({+ page,+ sentiment,+ message: message.trim(),+ email: email.trim() || undefined,+ }),+ });++ if (!response.ok) throw new Error('Failed to send');++ setState('success');+ setTimeout(() => {+ setIsOpen(false);+ setState('idle');+ setSentiment(null);+ setMessage('');+ setEmail('');+ }, 2000);+ } catch {+ setState('error');+ }+ };++ const handleClose = () => {+ setIsOpen(false);+ setState('idle');+ setSentiment(null);+ setMessage('');+ setEmail('');+ };++ return (+ <>+ <button+ onClick={() => setIsOpen(true)}+ className="inline-flex items-center gap-1.5 text-sm text-fd-muted-foreground hover:text-fd-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring"+ aria-label="Share feedback"+ >+ <MessageSquare className="w-4 h-4" aria-hidden="true" />+ Share feedback+ </button>++ {isOpen && (+ <div+ className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"+ onClick={handleClose}+ >+ <div+ className="bg-fd-background border border-fd-border rounded-lg shadow-lg w-full max-w-md mx-4 p-6"+ onClick={(e) => e.stopPropagation()}+ >+ <div className="flex items-center justify-between mb-4">+ <h2 className="text-lg font-semibold">Share feedback</h2>+ <button+ onClick={handleClose}+ className="text-fd-muted-foreground hover:text-fd-foreground transition-colors"+ aria-label="Close"+ >+ <X className="w-5 h-5" />+ </button>+ </div>++ {state === 'success' ? (+ <p className="text-green-600 text-center py-8">+ Thank you for your feedback!+ </p>+ ) : (+ <form onSubmit={handleSubmit}>+ <p className="text-sm text-fd-muted-foreground mb-4">+ Help us improve our documentation by sharing your thoughts.+ </p>++ <div className="flex gap-2 mb-4">+ {[+ { value: 'positive', emoji: 'π', label: 'Positive' },+ { value: 'neutral', emoji: 'π', label: 'Neutral' },+ { value: 'negative', emoji: 'π', label: 'Negative' },+ ].map((option) => (+ <button+ key={option.value}+ type="button"+ onClick={() => setSentiment(option.value as Sentiment)}+ className={`flex-1 py-2 px-3 rounded-md border text-xl transition-colors ${+ sentiment === option.value+ ? 'border-fd-primary bg-fd-primary/10'+ : 'border-fd-border hover:border-fd-muted-foreground'+ }`}+ aria-label={option.label}+ >+ {option.emoji}+ </button>+ ))}+ </div>++ <label className="block mb-4">+ <span className="text-sm font-medium">+ Your feedback <span className="text-red-500">*</span>+ </span>+ <textarea+ value={message}+ onChange={(e) => setMessage(e.target.value)}+ placeholder="Tell us what you thinkβ¦"+ required+ rows={4}+ className="mt-1 w-full px-3 py-2 border border-fd-border rounded-md bg-fd-background text-fd-foreground placeholder:text-fd-muted-foreground focus:outline-none focus:ring-2 focus:ring-fd-ring resize-none"+ />+ </label>++ <label className="block mb-6">+ <span className="text-sm font-medium">Email (optional)</span>+ <input+ type="email"+ value={email}+ onChange={(e) => setEmail(e.target.value)}+ placeholder="[email protected]"+ autoComplete="email"+ className="mt-1 w-full px-3 py-2 border border-fd-border rounded-md bg-fd-background text-fd-foreground placeholder:text-fd-muted-foreground focus:outline-none focus:ring-2 focus:ring-fd-ring"+ />+ </label>++ <div className="flex gap-3 justify-end">+ <button+ type="button"+ onClick={handleClose}+ className="px-4 py-2 text-sm font-medium text-fd-muted-foreground hover:text-fd-foreground transition-colors"+ >+ Cancel+ </button>+ <button+ type="submit"+ disabled={!message.trim() || state === 'loading'}+ className="px-4 py-2 text-sm font-medium bg-fd-primary text-fd-primary-foreground rounded-md hover:bg-fd-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors inline-flex items-center gap-2"+ >+ {state === 'loading' && <Loader2 className="w-4 h-4 animate-spin" />}+ {state === 'error' ? 'Try again' : 'Submit feedback'}+ </button>+ </div>+ </form>+ )}+ </div>+ </div>+ )}+ </>+ );+}diff --git a/docs/components/page-actions.tsx b/docs/components/page-actions.tsxindex 77e878ad7..57dc6ba66 100644--- a/docs/components/page-actions.tsx+++ b/docs/components/page-actions.tsx@@ -2,6 +2,7 @@import { useState } from 'react';import { Copy, Check, Loader2, ExternalLink } from 'lucide-react';+import { Feedback } from './feedback';interface PageActionsProps {path: string;@@ -64,6 +65,10 @@ export function PageActions({ path }: PageActionsProps) {<ExternalLink className="w-4 h-4" aria-hidden="true" />View as markdown</a>++ <span className="text-fd-muted-foreground/50" aria-hidden="true">Β·</span>++ <Feedback page={path} /></div>);}