Cookbooks · Agents that do things

A Hindi or Hinglish agent

An agent that speaks Hindi the way your callers do, in a voice recorded for it, and that follows a caller who drifts into English and back. It is three requests: read what is on offer, pick a voice, create the agent.

Before you start

  • An agent, and its ID. The Quickstart makes one.
  • A workspace API key in the CRACKLE_API_KEY environment variable. See Authentication.
  1. See which languages there are

    The catalog lists every language an agent can speak. Each has an id, which is what you will set on the agent.

    curl "https://goblins-call-api.onrender.com/v1/catalog" \
      -H "Authorization: Bearer $CRACKLE_API_KEY"
    catalog.languages (shortened)
    [
      { "id": "hi", "label": "Hindi", "iso": "hi", "native": "हिन्दी" },
      { "id": "hinglish", "label": "Hinglish", "iso": "hi", "native": "Hindi + English" },
      { "id": "en", "label": "English", "iso": "en" }
    ]

    Hindi is for callers who speak it throughout. Hinglish is Hindi with English words mixed in, the way it is commonly spoken. If your callers move between the two in one sentence, choose Hinglish.

  2. Pick a voice recorded in Hindi

    Ask the voice library for Hindi voices. Hinglish is spoken by Hindi voices, so either language name finds them.

    curl "https://goblins-call-api.onrender.com/v1/providers/voices?language=hinglish&gender=feminine&limit=10" \
      -H "Authorization: Bearer $CRACKLE_API_KEY"

    Each voice with preview: true has a sample. Listen before you choose; a voice is most of how an agent comes across.

    curl "https://goblins-call-api.onrender.com/v1/providers/voices/VOICE_ID/preview" \
      -H "Authorization: Bearer $CRACKLE_API_KEY" \
      --output sample.wav
  3. Create the agent

    Set the language and the voice, and say in the instructions how the agent should speak. changeLanguage lets it move between Hindi and English when the caller does.

    curl -X POST "https://goblins-call-api.onrender.com/v1/agents" \
      -H "Authorization: Bearer $CRACKLE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "name": "Tara",
      "systemInstruction": "You are Tara, and you answer calls for Sunrise Dental in Jaipur.\nSpeak Hinglish: everyday Hindi with the English words people really use, such as appointment, doctor and confirm.\nBe warm and brief. One or two short sentences per reply.\nIf the caller switches to English, switch with them, and switch back when they do.",
      "greetingInstruction": "Greet the caller warmly in Hinglish and ask how you can help.",
      "voice": {
        "language": "hinglish",
        "speaker": "VOICE_ID"
      },
      "systemTools": {
        "changeLanguage": true,
        "endCall": true
      }
    }'

Try it

Press Test agent in the studio and talk to it as your callers would. Switch to English for a sentence partway through and it should answer in English, then follow you back to Hindi.

Things to know

  • You can write the instructions in English, as here, or in Hindi. What matters is that they say which language to speak. Crackle adds writing rules for the voice on top, such as which script to write in and how to write numbers so they are read out properly.
  • Write names, addresses and product names in the instructions exactly as they should be said.
  • For a language other than Hindi or English, set the agent’s stt.language to that language’s iso code as well as voice.language, so the agent listens for the language it speaks. The studio does both when you pick a language there.
  • changeLanguage moves between Hindi and English only.