https://retellai.com/?utm_source=discord&utm_medium=seo logo
Internal Server Error when adding KB Source using ...
# ❓・bug-report
s
I am sending a simple request to add a source to an existing KB and it keeps throwing an Internal Server Error: URL: https://api.retellai.com/add-knowledge-base-sources/knowledge_base_4d79371e24dfd149 Body: { "knowledge_base_texts": [ { "title": "Test", "text": "This is a test knowledge base entry." } ] }
s
Can you share your org id
s
Is this what you are looking for - org_ZYiw74NnTAMyEXDg
Hello - any update on this?
s
I have reported the issue to team as soon get a reply I will tell you
s
ok thank you
Any response from the team? @Shehroze -Support @Retell
c
can you try this for me:
Copy code
const formData = new FormData();

// Add text source
formData.append("knowledge_base_texts[0][title]", "Test");
formData.append(
  "knowledge_base_texts[0][text]",
  "This is a test knowledge base entry."
);

const response = await fetch(
  "https://api.retellai.com/add-knowledge-base-sources/knowledge_base_4d79371e24dfd149",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_RETELL_API_KEY",
      // ⚠️ DO NOT set Content-Type
    },
    body: formData,
  }
);

const data = await response.json();
console.log(data);
can you also share your code you used to do this?
s
I am still getting internal server error running this (I am using make.com code module to run this) const formData = new FormData(); // Add text source formData.append("knowledge_base_texts[0][title]", "Test"); formData.append( "knowledge_base_texts[0][text]", "This is a test knowledge base entry." ); const response = await fetch( "https://api.retellai.com/add-knowledge-base-sources/knowledge_base_4d79371e24dfd149", { method: "POST", headers: { Authorization: "Bearer key_xxxxxxxxxxxxxxxxxxxxxxx", // ⚠️ DO NOT set Content-Type }, body: formData, } ); const data = await response.json(); console.log(data); https://cdn.discordapp.com/attachments/1457130128206200873/1459239996916764723/image.png?ex=69628ea6&is=69613d26&hm=a1e188229111b17b2cdbb06e473a93e22cf56d326d43ed6c66be0be56b1b414c&
I also used the same code and tried it with this change (changed index from 0 to 1) and that did not work. That KB already has a source so I wanted to add one formData.append("knowledge_base_texts[1][title]", "Test"); formData.append( "knowledge_base_texts[1][text]", "This is a test knowledge base entry."
Any update?
This is an urgent issue for us as we are not able to use rhe KB feature in our automated workflow
k
Brow, I'm having the same issue here, but to not waste more time, I make a little script in Python using the SDK, it was relatively quick to implements. And the main application run this script sending the payload. Nothing of HTTP request internaly, just run the script. This is a temporary solution while the API is being fixed.
o
Hello Guys , currently to use the knowledge base You have to use the SDK.
k
Can you help me here? How do I link a Knowledge Base to an agent using the API or the Python SDK? I dont find this on the doc.
o
what is your agent , single prompt or conversation flow ?
k
Conversation flow
o
k
Thanks!
s
Thanks
o
Hello Guys , you can know create kb through the API , Try this code : `import fs from 'fs'; const token = 'key_XXX'; const url = 'https://api.retellai.com/create-knowledge-base'; async function createKB() { const formData = new FormData(); formData.append('knowledge_base_name', 'Sample KB'); formData.append('knowledge_base_texts', JSON.stringify([ { title: "Sample Question", text: "Hello, how are you?" } ])); formData.append('knowledge_base_urls', JSON.stringify([ "https://www.retellai.com", "https://docs.retellai.com" ])); const fileBuffer = fs.readFileSync('./test_data.txt'); const blob = new Blob([fileBuffer], { type: 'text/plain' }); formData.append('knowledge_base_files', blob, 'test_data.txt'); try { const response = await fetch(url, { method: "POST", headers: { Authorization:
Bearer ${token}
}, body: formData }); const result = await response.json(); console.log("Success:", JSON.stringify(result, null, 2)); } catch (error) { console.error("Error:", error); } } createKB();`
s
This is still not working for me
@David Adedoyin chapell helped me with this and I am able to use the API now as well
o
Hello @Sanjay , what error do you see when trying to do this ?
and can you share the request , and your org id .
s
It is working now with thr API which is my preferred method so I am good now
Not sure why you mentioned to only use the SDK but it is working with the API in a very convoluted way
o
There was an issue and its fixed
you can see I mentiond that you can use the API Again above
Great to hear, let me know if you need anything else .
k
Hello @Omar Ashraf | Community Lead, how I can use the auto-crawling when add a source to the KB? If I add a URL by API, on the Retell dashboard there is only one page, but if I add a source by Retell Dashboard, there are more than 200 pages.
d
I can help you @Kogu
k
Hi! Any return?
d
When you add a URL via the API, Retell currently treats it as a single-page source. Auto-crawling (following internal links and ingesting multiple pages) is only triggered when the source is added through the Retell dashboard UI. If you want the same ~200-page crawl via API, you’d need to either add the source from the dashboard or programmatically submit each page URL individually. Happy to help you set up a workaround if needed.
k
Thanks! Another question, about refresh, I don't find a way to refresh only one source, or the entire KB. There's a way to do that or only by the
enable_auto_refresh
element when create a KB?