@devries-cameron20 / composio Mirror · read-only / commits / 5f1fe0c31
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 14:30 UTC

feat(docs): add share feedback button with Slack integration

- Add Feedback modal component (Geist-style) - Add API route that posts to Slack webhook - Add SLACK_FEEDBACK_WEBHOOK_URL to .env.example Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 19, 2026 at 15:11 UTC 5f1fe0c31c6425a5b1e7f0edde9b78c2a1fc07fe
4 files changed +266
docs/.env.example
+3
@@ -8,3 +8,6 @@ OPENAPI_SPEC_URL=https://backend.composio.dev/api/v3/openapi.json
8 # PostHog Analytics (optional)
9 NEXT_PUBLIC_POSTHOG_KEY=your_posthog_project_api_key
10 NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com
11 +
12 +# Slack webhook for docs feedback (create at https://api.slack.com/apps)
13 +SLACK_FEEDBACK_WEBHOOK_URL=https://hooks.slack.com/services/xxx/xxx/xxx
docs/app/api/feedback/route.ts new
+85
@@ -0,0 +1,85 @@
1 +import { NextRequest, NextResponse } from 'next/server';
2 +
3 +const SLACK_WEBHOOK_URL = process.env.SLACK_FEEDBACK_WEBHOOK_URL;
4 +
5 +const sentimentEmoji: Record<string, string> = {
6 + positive: '😊',
7 + neutral: '😐',
8 + negative: '😞',
9 +};
10 +
11 +export async function POST(request: NextRequest) {
12 + if (!SLACK_WEBHOOK_URL) {
13 + console.error('SLACK_FEEDBACK_WEBHOOK_URL is not configured');
14 + return NextResponse.json({ error: 'Feedback not configured' }, { status: 500 });
15 + }
16 +
17 + try {
18 + const { page, sentiment, message, email } = await request.json();
19 +
20 + if (!message?.trim()) {
21 + return NextResponse.json({ error: 'Message is required' }, { status: 400 });
22 + }
23 +
24 + const emoji = sentiment ? sentimentEmoji[sentiment] || '' : '';
25 +
26 + const slackMessage = {
27 + blocks: [
28 + {
29 + type: 'header',
30 + text: {
31 + type: 'plain_text',
32 + text: `${emoji} New Docs Feedback`,
33 + emoji: true,
34 + },
35 + },
36 + {
37 + type: 'section',
38 + fields: [
39 + {
40 + type: 'mrkdwn',
41 + text: `*Page:*\n<https://composio.dev${page}|${page}>`,
42 + },
43 + {
44 + type: 'mrkdwn',
45 + text: `*Sentiment:*\n${sentiment || 'Not specified'}`,
46 + },
47 + ],
48 + },
49 + {
50 + type: 'section',
51 + text: {
52 + type: 'mrkdwn',
53 + text: `*Feedback:*\n${message}`,
54 + },
55 + },
56 + ...(email
57 + ? [
58 + {
59 + type: 'section',
60 + text: {
61 + type: 'mrkdwn',
62 + text: `*Email:*\n${email}`,
63 + },
64 + },
65 + ]
66 + : []),
67 + ],
68 + };
69 +
70 + const response = await fetch(SLACK_WEBHOOK_URL, {
71 + method: 'POST',
72 + headers: { 'Content-Type': 'application/json' },
73 + body: JSON.stringify(slackMessage),
74 + });
75 +
76 + if (!response.ok) {
77 + throw new Error('Failed to send to Slack');
78 + }
79 +
80 + return NextResponse.json({ success: true });
81 + } catch (error) {
82 + console.error('Feedback error:', error);
83 + return NextResponse.json({ error: 'Failed to submit feedback' }, { status: 500 });
84 + }
85 +}
docs/components/feedback.tsx new
+173
@@ -0,0 +1,173 @@
1 +'use client';
2 +
3 +import { useState } from 'react';
4 +import { MessageSquare, X, Loader2 } from 'lucide-react';
5 +
6 +type Sentiment = 'positive' | 'neutral' | 'negative' | null;
7 +
8 +interface FeedbackProps {
9 + page: string;
10 +}
11 +
12 +export function Feedback({ page }: FeedbackProps) {
13 + const [isOpen, setIsOpen] = useState(false);
14 + const [sentiment, setSentiment] = useState<Sentiment>(null);
15 + const [message, setMessage] = useState('');
16 + const [email, setEmail] = useState('');
17 + const [state, setState] = useState<'idle' | 'loading' | 'success' | 'error'>('idle');
18 +
19 + const handleSubmit = async (e: React.FormEvent) => {
20 + e.preventDefault();
21 + if (!message.trim()) return;
22 +
23 + setState('loading');
24 +
25 + try {
26 + const response = await fetch('/api/feedback', {
27 + method: 'POST',
28 + headers: { 'Content-Type': 'application/json' },
29 + body: JSON.stringify({
30 + page,
31 + sentiment,
32 + message: message.trim(),
33 + email: email.trim() || undefined,
34 + }),
35 + });
36 +
37 + if (!response.ok) throw new Error('Failed to send');
38 +
39 + setState('success');
40 + setTimeout(() => {
41 + setIsOpen(false);
42 + setState('idle');
43 + setSentiment(null);
44 + setMessage('');
45 + setEmail('');
46 + }, 2000);
47 + } catch {
48 + setState('error');
49 + }
50 + };
51 +
52 + const handleClose = () => {
53 + setIsOpen(false);
54 + setState('idle');
55 + setSentiment(null);
56 + setMessage('');
57 + setEmail('');
58 + };
59 +
60 + return (
61 + <>
62 + <button
63 + onClick={() => setIsOpen(true)}
64 + 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"
65 + aria-label="Share feedback"
66 + >
67 + <MessageSquare className="w-4 h-4" aria-hidden="true" />
68 + Share feedback
69 + </button>
70 +
71 + {isOpen && (
72 + <div
73 + className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"
74 + onClick={handleClose}
75 + >
76 + <div
77 + className="bg-fd-background border border-fd-border rounded-lg shadow-lg w-full max-w-md mx-4 p-6"
78 + onClick={(e) => e.stopPropagation()}
79 + >
80 + <div className="flex items-center justify-between mb-4">
81 + <h2 className="text-lg font-semibold">Share feedback</h2>
82 + <button
83 + onClick={handleClose}
84 + className="text-fd-muted-foreground hover:text-fd-foreground transition-colors"
85 + aria-label="Close"
86 + >
87 + <X className="w-5 h-5" />
88 + </button>
89 + </div>
90 +
91 + {state === 'success' ? (
92 + <p className="text-green-600 text-center py-8">
93 + Thank you for your feedback!
94 + </p>
95 + ) : (
96 + <form onSubmit={handleSubmit}>
97 + <p className="text-sm text-fd-muted-foreground mb-4">
98 + Help us improve our documentation by sharing your thoughts.
99 + </p>
100 +
101 + <div className="flex gap-2 mb-4">
102 + {[
103 + { value: 'positive', emoji: '😊', label: 'Positive' },
104 + { value: 'neutral', emoji: '😐', label: 'Neutral' },
105 + { value: 'negative', emoji: '😞', label: 'Negative' },
106 + ].map((option) => (
107 + <button
108 + key={option.value}
109 + type="button"
110 + onClick={() => setSentiment(option.value as Sentiment)}
111 + className={`flex-1 py-2 px-3 rounded-md border text-xl transition-colors ${
112 + sentiment === option.value
113 + ? 'border-fd-primary bg-fd-primary/10'
114 + : 'border-fd-border hover:border-fd-muted-foreground'
115 + }`}
116 + aria-label={option.label}
117 + >
118 + {option.emoji}
119 + </button>
120 + ))}
121 + </div>
122 +
123 + <label className="block mb-4">
124 + <span className="text-sm font-medium">
125 + Your feedback <span className="text-red-500">*</span>
126 + </span>
127 + <textarea
128 + value={message}
129 + onChange={(e) => setMessage(e.target.value)}
130 + placeholder="Tell us what you think…"
131 + required
132 + rows={4}
133 + 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"
134 + />
135 + </label>
136 +
137 + <label className="block mb-6">
138 + <span className="text-sm font-medium">Email (optional)</span>
139 + <input
140 + type="email"
141 + value={email}
142 + onChange={(e) => setEmail(e.target.value)}
143 + placeholder="your@email.com"
144 + autoComplete="email"
145 + 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"
146 + />
147 + </label>
148 +
149 + <div className="flex gap-3 justify-end">
150 + <button
151 + type="button"
152 + onClick={handleClose}
153 + className="px-4 py-2 text-sm font-medium text-fd-muted-foreground hover:text-fd-foreground transition-colors"
154 + >
155 + Cancel
156 + </button>
157 + <button
158 + type="submit"
159 + disabled={!message.trim() || state === 'loading'}
160 + 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"
161 + >
162 + {state === 'loading' && <Loader2 className="w-4 h-4 animate-spin" />}
163 + {state === 'error' ? 'Try again' : 'Submit feedback'}
164 + </button>
165 + </div>
166 + </form>
167 + )}
168 + </div>
169 + </div>
170 + )}
171 + </>
172 + );
173 +}
docs/components/page-actions.tsx
+5
@@ -2,6 +2,7 @@
2
3 import { useState } from 'react';
4 import { Copy, Check, Loader2, ExternalLink } from 'lucide-react';
5 +import { Feedback } from './feedback';
6
7 interface PageActionsProps {
8 path: string;
@@ -64,6 +65,10 @@ export function PageActions({ path }: PageActionsProps) {
65 <ExternalLink className="w-4 h-4" aria-hidden="true" />
66 View as markdown
67 </a>
68 +
69 + <span className="text-fd-muted-foreground/50" aria-hidden="true">·</span>
70 +
71 + <Feedback page={path} />
72 </div>
73 );
74 }