Skip to content
Voiceflow
0:09:01
321
10
8
Last update : 11/09/2024

Unlocking Ultimate Control: Mastering Voiceflow’s Knowledge Base Query API 🤖

Have you ever wished you had more control over how your Voiceflow AI agent responds to user questions? Instead of relying solely on Voiceflow’s built-in AI, you can tap into the raw power of the Knowledge Base Query API. This approach gives you granular control over the information used to craft responses, leading to more accurate and sophisticated interactions.

Why This Matters 🤔

Imagine this: your users are asking complex questions, and you need your AI agent to provide precise and insightful answers. This is where the Knowledge Base Query API comes in. It allows you to bypass the standard AI response generation and take the reins yourself, crafting the perfect answer every time.

Deconstructing the Query API 🧩

Think of the Query API as a bridge between your Voiceflow agent and your knowledge base. Instead of just getting a pre-packaged answer, you get access to the building blocks:

  • Chunks: These are the raw pieces of information extracted from your knowledge base that are relevant to the user’s question.
  • Messages: This is the behind-the-scenes information that’s usually sent to the AI model, including the context and instructions for generating a response.
  • Output: This is the final answer that the AI model would typically generate.

By using the Query API, you can grab these “chunks” of information and feed them into your own AI step, giving you complete control over how the final answer is generated.

Step-by-Step Implementation 🏗️

Ready to dive in? Here’s how to harness the power of the Query API:

  1. Access Your API Key: Head to the “Integrations” section in your Voiceflow project to find your unique API key. This key acts like a passport, granting you access to your knowledge base data. 🔑

  2. Set Up Your API Step: In your Voiceflow canvas, drag and drop an API step. Configure it as a “POST” request and input the Query API endpoint URL from the Voiceflow documentation.

  3. Add Headers: Think of headers as instructions for your API call. You’ll need to include three key headers:

    • Authorization: Paste your API key here.
    • Accept: Set this to “application/json”.
    • Content-Type: Set this to “application/json” as well.
  4. Craft the Body: The body of your API request is where you’ll specify the question you want to ask your knowledge base. Use the “raw” input format and structure your request like this:

   {
     "question": "{last_utterance}",
     "synthesis": false,
     "chunkLimit": 5
   }
  • Replace {last_utterance} with the actual user input variable from your Voiceflow project.
  • Setting "synthesis": false ensures you receive the raw “chunks” without any AI-generated responses.
  • "chunkLimit": 5 tells the API to return a maximum of 5 relevant chunks. You can adjust this number as needed.
  1. Capture the Response: Use a “Capture” step to store the API response in a variable. Name this variable “response”.

  2. Extract the Chunks: Since the “chunks” are nested within the “response” object, you’ll need to extract them. Use a “Set” step and the following code:

   stringify(response.chunks)

This converts the “chunks” array into a string that Voiceflow can easily display and work with.

  1. Unleash the AI: Now, drag in a “Response AI” step. This is where you’ll craft your custom AI prompt using the extracted “chunks” as reference information.

    For example:

   Answer the customer question accurately using only the reference information provided.

   User question is: {last_utterance}

   Reference information is: {chunks} 

This prompt instructs the AI to generate an answer based on the user’s question and the relevant information extracted from your knowledge base.

Reaping the Rewards 🏆

By mastering the Knowledge Base Query API, you gain:

  • Precision Engineering: Craft highly specific and accurate answers tailored to your users’ needs.
  • Hallucination Control: Minimize the risk of your AI providing inaccurate or fabricated information.
  • Advanced Interactions: Implement sophisticated features like follow-up questions and context-aware responses.

🧰 Resource Toolbox

  • Voiceflow Documentation – Knowledge Base APIs: https://docs.voiceflow.com/ – Your go-to resource for understanding the ins and outs of the Knowledge Base Query API.
  • Voiceflow Community Forum: https://link.voiceflow.com/community – Connect with other Voiceflow users and experts to get help and share your experiences.

This approach might seem like a bit more work upfront, but the payoff is immense. You’ll be able to create a truly intelligent and helpful AI agent that can tackle even the most challenging user interactions.

Other videos of

Play Video
Voiceflow
0:28:51
123
12
0
Last update : 19/09/2024
Play Video
Voiceflow
0:03:17
64
7
4
Last update : 18/09/2024
Play Video
Voiceflow
0:05:56
256
22
1
Last update : 18/09/2024
Play Video
Voiceflow
0:03:16
76
9
2
Last update : 18/09/2024
Play Video
Voiceflow
0:06:44
140
7
5
Last update : 18/09/2024
Play Video
Voiceflow
0:05:27
127
8
0
Last update : 18/09/2024
Play Video
Voiceflow
0:18:02
1 608
56
9
Last update : 18/09/2024
Play Video
Voiceflow
0:48:09
1 244
55
11
Last update : 18/09/2024
Play Video
Voiceflow
0:04:54
193
9
2
Last update : 11/09/2024