Knowledge base result not used by voice assistant
# support
a
Hey guys, I'm trying the full custom knowledge base, i've a webhook that is called when i ask informations to the assistant. What i'm testing is simple: - "Can you tell me how old i am" And I try to return a static answer: - "You are 30 years old" You can see the knowledge-base is correctly queried in this call log :
019a37d9-f4f2-7ff0-82f0-1c479242798c
You can also see the data i return:
Copy code
attributes.response.data.message.content: you are 30 years old
attributes.response.data.message.role: assistant
You can see on the call log that the AI does not use the answser from the knowledge base, What am I missing ? Thanks !
v
Hey! I can help you sort that out. It looks like your webhook is returning the data correctly, but Vapi might not be mapping the response to the assistant’s message context. Can you confirm if your webhook is returning the response in the proper messages array format (like { messages: [{ role: "assistant", content: "You are 30 years old" }] }) rather than under attributes.response.data? Once you confirm that, I can guide you on the exact response structure Vapi expects so your custom knowledge output gets injected properly into the assistant’s reply. @axel@tell-ia
a
hey @Vignxt Flow thank having a look, My webhook currently returns
Copy code
return {
  "message": {
    "role": "assistant",
    "content": "you are 30 years old"
  }
};
which i took from the [doc](https://docs.vapi.ai/knowledge-base/custom-knowledge-base#option-2-return-direct-response) I will try to do this instead then :
Copy code
return {
  messages: [
      "message": {
        "role": "assistant",
        "content": "you are 30 years old"
      }
  ]
};
I just tried with this payload:
Copy code
➜  curl -X POST localhost:3888/vapi/webhooks/custom-knowledge-base/search
{"messages":[{"role":"assistant","content":"There are 4 trucks available."}]}%
The id of the call is
019a3b1f-9214-7225-b913-80c2a25b7b31
When i'm mentionning the
attributesresponse.data
htat's because i see it on the VAPI dashboard like this: (see screenshot attached) https://cdn.discordapp.com/attachments/1433628349133230151/1433858324960379002/image.png?ex=69063820&is=6904e6a0&hm=a4e61c4628e2074ff0cde429735f1820f98ff5be2a30227a2a9d1ff291fb4aef&
Ok resolved ! ✔️ the proper payload is :
Copy code
return {
      message: {
        type: 'custom-message',
        content: 'There are 4 trucks available.',
      }
    };
c
Hi Le Rutabaga, It looks like you may have a question about integrating or using a Knowledge Base with your voice AI assistant. To effectively set up and utilize Knowledge Bases, you can follow these steps: 1. **Create a Knowledge Base**: You can do this via the Vapi dashboard or API. For the dashboard method, simply upload your relevant files under
Build > Files
and configure your assistant accordingly. More details can be found in the [Knowledge Base instructions](https://docs.vapi.ai/knowledge-base). 2. **Configure a Query Tool**: Use the Query Tool feature to enable your assistant to access knowledge bases. Choose either the dashboard or API to set up the tool by associating it with your desired files using file IDs. Instructions are available in the [Query Tool guide](https://docs.vapi.ai/knowledge-base/using-query-tool). 3. **Attach to Assistant**: Ensure that the Query Tool is integrated into your assistant's workflow. On the dashboard, select your assistant and attach the tool under the Tools section. Update the system prompts to instruct when to use the tool. By ensuring these steps are correctly implemented and using detailed, descriptive prompts within your assistant configuration, your assistant should effectively retrieve and verbalize responses from the Knowledge Base. If you encounter issues with your assistant not using the Knowledge Base, ensure that the setup is correctly configured and test the assistant thoroughly, checking the system prompts and tool attachment. For any further detailed challenge or specific configurations, the related documents linked above can offer more guidance.
a
Hey, thanks for your answer, but: 1. as written, the issue is currently "resolved" 2. the issue is coming from the VAPI documentation which is not up to date, particularly the response schema to send as answer for a webhook call is wrong in the documentation page and does not reflect what needed to be sent
c
Could you send us the call id where you had the successful payload? We would like to review it in case we need to update our documentation page
4 Views