पेश है Eleven v4पेश है Eleven v4, हमारा अब तक का सबसे भावपूर्ण मॉडल।

कंटेंट पर जाएं

अपने React ऐप में मिनटों में Santa वॉइस एजेंट जोड़ें

प्रकाशित

सुनेंइस आर्टिकल को सुनें

इस छुट्टियों के मौसम में, अपने ऐप में सांता को जोड़ें।

ElevenLabs के Agents Platform और @elevenlabs/react SDK के साथ, आप सांता क्लॉज़ वॉइस एजेंट को कुछ ही मिनटों में अपने React ऐप में जोड़ सकते हैं। इस गाइड में हम:

  1. ElevenLabs डैशबोर्ड में सांता एजेंट बनाएं
  2. WebRTC का उपयोग करके उसे React कंपोनेंट में सेट अप करें
  3. एक आसान “Call Santa” बटन जोड़ें

1. साइन अप करें और Agents Platform खोलें

  1. साइन अप करें / लॉग इन करें ElevenLabs में।
  2. बाईं साइडबार में, सबसे ऊपर platform switcher खोलें।
  3. चुनें Agents Platform।

आपको “Build” सेक्शन के अंतर्गत Agents, Knowledge Base, Tools, और Voices वाली साइडबार दिखेगी।

2. अपना सांता एजेंट बनाएं

अब हम एक ऐसा एजेंट बनाएंगे जो सांता की तरह व्यवहार करे और सांता जैसी आवाज़ में बोले।

  1. साइडबार में Agents पर क्लिक करें।
  2. क्लिक करें + New Agent।
  3. चुनें Blank Agent और बिल्कुल शुरुआत से शुरू करें।

नाम रखें: Santa।

सिस्टम प्रॉम्प्ट

System Prompt फ़ील्ड में, यह पेस्ट करें:

You are a helpful assistant. You are Santa Claus, a jolly, warm, and humorous character from the North Pole. Christmas is just around the corner, and you love reminding everyone of the festive season with your hearty "Ho, ho, ho!" You are deeply in love with Mrs. Claus, often mentioning her incredible cookies.

When speaking to someone, keep your answers short and magical—just one festive sentence. Make it your top priority to ask for their name to check your naughty or nice list. Once you have their name, immediately ask about their wish-list, as it's crucial for your preparations. Always be warm and gentle.

Once their name and wish-list are covered, guide the conversation toward learning more about what they've done throughout the year and why they believe they deserve to be on Santa's Nice List. Use this opportunity to celebrate their kindness or achievements, reinforcing the importance of spreading goodness and holiday cheer. You also love asking about their plans for the holidays and showing genuine interest in their answers. Compliment them if you know they've done something kind or helpful recently, reinforcing the importance of spreading goodness.

Talk about your favorite gifts you've delivered or share quick, magical details about life at the North Pole, like mischievous elves or your reindeer team. Sprinkle in lighthearted jokes about your endless to-do list or how you struggle to resist cookies left out for you on Christmas Eve. Always express how much you love seeing people happy during the holidays and how their smiles make all your efforts worthwhile.

If the user makes a request involving inappropriate, harmful, or dangerous items such as weapons or items that go against the spirit of Christmas. Politely remind the user to make kind and festive wishes instead.

End every conversation with a warm farewell, suggesting you must return to your holiday preparations to ensure everyone gets their gifts on time. Wish them a Merry Christmas and encourage them to spread kindness and holiday cheer. Stay cheerful, engaging, and full of festive energy, spreading Christmas magic through humor, warmth, and storytelling.

Be sure to maintain the conversation in the user's selected language.

पहला संदेश

First Message को यह सेट करें:

हो, हो, हो! मेरी दोस्त, आपको क्रिसमस की शुभकामनाएं। बताइए, आपका नाम क्या है?

कॉल शुरू होने पर यूज़र यही सुनेंगे।

आवाज़

Voice सेक्शन में:

  • चुनें “Jerry B. – Santa Claus”
  • वॉइस ID: MDLAMJ0jxkpYkjXbmG4t

अब सांता की आवाज़ सच में सांता जैसी लगेगी।

सुरक्षा

इस उदाहरण के लिए, इसे खुला ही रखेंगे:

  • Security में, यह पक्का करें कि Enable authentication बंद हो।

अपने पहले डेमो के लिए Enable Authentication को बंद रखना बिल्कुल ठीक है, ताकि कोई भी बिना किसी पाबंदी के एजेंट से कनेक्ट हो सके। इससे ऑनबोर्डिंग तेज़ होती है और यह क्विक प्रोटोटाइप, हैकाथॉन प्रोजेक्ट या इंटरनल शोकेस के लिए आदर्श है।

हालांकि, किसी भी प्रोडक्शन या बाहरी तौर पर उपलब्ध ऐप्लिकेशन के लिए, आपको अपने एजेंट को कभी भी खुला नहीं छोड़ना चाहिए। इसके बजाय, हर यूज़र सेशन के लिए सीमित अवधि और दायरे वाले एक्सेस टोकन जनरेट करने हेतु ElevenLabs Token Endpoint का इस्तेमाल करें। इससे आप पूरी तरह नियंत्रित कर सकते हैं कि कौन कनेक्ट कर सकता है, एक्सेस कितनी देर रहेगा और यूज़र कौन-से काम कर सकता है। ऑथेंटिकेशन चालू करने से आपका एजेंट अनधिकृत कॉल, दुरुपयोग या आपकी तय सीमाओं के बाहर इस्तेमाल से सुरक्षित रहता है — और लाइव होने से पहले इसकी पुरज़ोर सलाह दी जाती है।

3. अपना एजेंट ID लें

एजेंट पेज के सबसे ऊपर, आपको Agent ID फ़ील्ड दिखेगी।

इस वैल्यू को नोट कर लें — अगले चरण में हम इसे अपने React कंपोनेंट में पेस्ट करेंगे:

agentId: "<AGENT_ID>"

4. React SDK इंस्टॉल करें

अपने React / Next.js प्रोजेक्ट में ElevenLabs React SDK इंस्टॉल करें:

npm install @elevenlabs/react

इसके बाद, हम वॉइस कॉल शुरू और बंद करने के लिए useConversation हुक का इस्तेमाल कर सकते हैं।

5. “Call Santa” बटन जोड़ें

एक नया कंपोनेंट बनाएं, जैसे CallSantaButton.tsx, और यह कोड पेस्ट करें:

"use client";

import { useConversation } from "@elevenlabs/react";
import { useCallback, useState } from "react";

export function CallButton() {
  const [hasPermission, setHasPermission] = useState(false);
  const [permissionError, setPermissionError] = useState<string | null>(null);

  const conversation = useConversation();

  const requestMicrophonePermission = useCallback(async () => {
    try {
      await navigator.mediaDevices.getUserMedia({ audio: true });
      setHasPermission(true);
      setPermissionError(null);
      return true;
    } catch {
      setPermissionError("Microphone access is required");
      return false;
    }
  }, []);

  const startCall = useCallback(async () => {
    const permitted = hasPermission || (await requestMicrophonePermission());
    if (!permitted) return;

    try {
      await conversation.startSession({
        agentId: "<AGENT_ID>",
        connectionType: "webrtc",
      });
    } catch (error) {
      console.error("Failed to start conversation:", error);
    }
  }, [conversation, hasPermission, requestMicrophonePermission]);

  const endCall = useCallback(async () => {
    await conversation.endSession();
  }, [conversation]);

  const isConnected = conversation.status === "connected";

  return (
    <div className="flex flex-col items-center gap-4">
      <button
        onClick={isConnected ? endCall : startCall}
        className={`px-6 py-3 rounded-lg text-white font-medium ${
          isConnected
            ? "bg-red-600 hover:bg-red-700"
            : "bg-green-600 hover:bg-green-700"
        }`}
      >
        {isConnected ? "End Call" : "Start Call"}
      </button>

      {isConnected && (
        <p className="text-sm text-gray-600">
          {conversation.isSpeaking ? "Agent speaking..." : "Listening..."}
        </p>
      )}

      {permissionError && (
        <p className="text-sm text-red-500">{permissionError}</p>
      )}
    </div>
  );
}

अब बदलें "<AGENT_ID>" को डैशबोर्ड से कॉपी की गई असली Agent ID से।

फिर अपने UI में कहीं भी बटन रेंडर करें, उदाहरण के लिए:

import { CallButton } from "./CallSantaButton";

export default function HomePage() {
  return (
    <main className="min-h-screen flex flex-col items-center justify-center gap-6">
      <h1 className="text-3xl font-bold text-center">
        Call Santa 🎅
      </h1>
      <p className="text-gray-600">
        Press the button and talk to Santa in real time.
      </p>
      <CallButton />
    </main>
  );
}

6. आज़माएं

इसे अपने ब्राउज़र में खोलें और Start Call पर क्लिक करें:

  1. आपका ब्राउज़र माइक्रोफ़ोन की अनुमति मांगेगा।
  2. आपके सांता एजेंट के साथ एक WebRTC सेशन शुरू होगा।
  3. आप सुनेंगे:

    “हो, हो, हो! मेरी दोस्त, आपको क्रिसमस की शुभकामनाएं। बताइए, आपका नाम क्या है?”

इसके बाद सांता आपका नाम, विशलिस्ट और इस साल आपने नाइस लिस्ट में बने रहने के लिए क्या किया है, इसके बारे में पूछेगा।

आगे क्या करें

बुनियादी सेटअप काम करने लगे, तो आप:

  • सांता को ऑथ के पीछे सीमित कर सकते हैं एजेंट की Security सेटिंग्स का इस्तेमाल करके
  • भाषाएं बदल सकते हैं यूज़र लोकेल पास करके और प्रॉम्प्ट को संभालने देकर
  • UI को कस्टमाइज़ कर सकते हैं कस्टम बटन, ऐनिमेशन या पूरे “Call Santa” स्क्रीन के साथ

लेकिन मुख्य इंटीग्रेशन बस इतना है:

  • एक एजेंट Agents Platform में
  • एक agentId
  • एक useConversation हुक और एक बटन

अपने React ऐप में रियल-टाइम, बातचीत वाला सांता जादू लाने के लिए आपको बस इतना ही चाहिए।

संबंधित लेख

उच्चतम गुणवत्ता वाले AI ऑडियो के साथ बनाएं