cjo93 commited on
Commit
d018935
·
verified ·
1 Parent(s): 0e7bae7

Create src/components/defrag/eleven-labs-agent.tsx

Browse files
src/components/defrag/eleven-labs-agent.tsx ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client";
2
+
3
+ import { useEffect } from 'react';
4
+
5
+ export function ElevenLabsAgent() {
6
+ // Uses environment variable or falls back to null if not set
7
+ const agentId = process.env.NEXT_PUBLIC_ELEVENLABS_AGENT_ID;
8
+
9
+ useEffect(() => {
10
+ if (!agentId) return;
11
+
12
+ const script = document.createElement('script');
13
+ script.src = 'https://elevenlabs.io/convai-widget/index.js';
14
+ script.async = true;
15
+ script.type = 'text/javascript';
16
+ document.body.appendChild(script);
17
+
18
+ return () => {
19
+ document.body.removeChild(script);
20
+ };
21
+ }, [agentId]);
22
+
23
+ if (!agentId) return null;
24
+
25
+ return (
26
+ <div className="fixed bottom-4 right-4 z-[100]">
27
+ {/* @ts-ignore */}
28
+ <elevenlabs-convai agent-id={agentId} />
29
+ </div>
30
+ );
31
+ }