https://retellai.com/?utm_source=discord&utm_medium=seo logo
I have an issue with the add sources to knowledge ...
# ❓・ai-evy-support
y
@AI Evy I have an issue with the add sources to knowledge base endpoint. Is it broken? I tried with SDK and with the testing function on the documentation and none seem to work
a
Thanks for tagging me @YasserSE. I'll look through relevant sources and get back to you shortly.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] API knowledge base bug](https://discord.com/channels/1186424376300679209/1448946789385371668) [[2] Add Knowledge Base Sources](https://docs.retellai.com/api-references/add-knowledge-base-sources) [[3] Get Knowledge Base](https://docs.retellai.com/api-references/get-knowledge-base) ​
### Answer --- Based on community reports, the
addSources
endpoint has had intermittent issues. [(1) ]() One user reported that Retell confirmed it was fixed after experiencing similar 400/500 errors. Recommended approach: Use the official SDK rather than direct REST API calls. Here's the correct SDK usage:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
async function main() {
  const knowledgeBaseResponse = await client.knowledgeBase.addSources({
    knowledge_base_texts: [
      {
        text: "Hello, how are you?",
        title: "Sample Question",
      },
    ],
    knowledge_base_urls: [
      "<https://www.retellai.com%22,>
      "<https://docs.retellai.com%22,>
    ],
    knowledge_base_files: [
      fs.createReadStream("../sample.txt") ,
    ],
  }) ;
  console.log(knowledgeBaseResponse.knowledge_base_id) ;
}
main() ;
[(2) ]() If you're still experiencing issues: 1. Confirm your knowledge base exists and note its status using the retrieve endpoint [(3) ]() 2. Ensure you're passing the
knowledge_base_id
as a path parameter [(2) ]() 3. The Knowledge Base API for create/add only works for the SDK now [(1) ]() Workaround: If
addSources
continues to fail, creating a new knowledge base with
knowledgeBase.create()
works reliably. If the issue persists, reach out to support at [Contact Sales]() or check [) .
y
@AI Evy In get this Failed to sync with Retell KB: TypeError: retell_sdk__WEBPACK_IMPORTED_MODULE_0___default(...) is not a constructor
a
Thanks for the follow-up, @YasserSE. I'll get back to you soon.
### Answer This error typically occurs when using the wrong import syntax for the Retell SDK in a bundler environment (like Webpack) . The SDK uses ES module exports. Correct import syntax:
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
[(1) ]() , [(2) ]() Common causes of this error: 1. Using CommonJS
require()
syntax instead of ES module
import
2. Incorrect default import handling in your bundler configuration 3. Missing or outdated
retell-sdk
package Steps to resolve: 1. Ensure you're using the ES module import syntax shown above [(1) ]() 2. Verify the SDK is installed:
npm install retell-sdk
3. Check that your project supports ES modules (Node.js 18.10.0+ is required) If you're in a CommonJS environment and cannot use ES imports, you may need to adjust your bundler configuration or use dynamic imports.
​ To learn more, see the sources I considered: [[1] SDKs](https://docs.retellai.com/get-started/sdk) [[2] Retell Node API Library](https://github.com/RetellAI/retell-typescript-sdk/blob/main/README.md) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
y
@AI Evy GET /api/cx-support/extra-prompts 200 in 360ms [cx-support/extra-prompts] Failed to sync with Retell KB: TypeError: Cannot read properties of undefined (reading 'default') at getRetellClient (webpack-internal:///(rsc)/./lib/retell-kb.ts:25:209) at addToRetellKB (webpack-internal:///(rsc)/./lib/retell-kb.ts:61:20) at syncPromptWithRetellKB (webpack-internal:///(rsc)/./lib/retell-kb.ts:117:15) at PATCH (webpack-internal:///(rsc)/./app/api/cx-support/extra-prompts/route.ts:76:97) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
a
Thanks for the follow-up, @YasserSE. I'll get back to you soon.
### Answer This error (
Cannot read properties of undefined (reading 'default')
) indicates a module resolution issue with the Retell SDK in your Next.js RSC (React Server Components) environment. Known Issue: There's a reported compatibility problem with Turbopack in Next.js 15.2 and the Retell SDK. [(1) ]() Recommended workaround: Use Next.js 14 for now. The Retell team is still working to fix this. If you must use Next.js 15: 1. Disable Turbopack by running
next dev
without the
--turbo
flag 2. Ensure you're using the correct import syntax:
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
[(2) ]() , [(3) ]() 3. For environments where the global fetch needs to be used instead of node-fetch, add this import before your Retell import:
Copy code
javascript
import 'retell-sdk/shims/web';
import Retell from 'retell-sdk';
Requirements: Node.js 18.10.0 or higher is required for the Node.js SDK. [(2) ]() If the issue persists after disabling Turbopack, reach out via [Contact Sales]() or check [) .
​ To learn more, see the sources I considered: [[1] Problem with Turbopack Next 15.2 and Retell 4.19.0](https://discord.com/channels/1186424376300679209/1346664384151421030) [[2] SDKs](https://docs.retellai.com/get-started/sdk) [[3] Retell Node API Library](https://github.com/RetellAI/retell-typescript-sdk/blob/main/README.md) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
y
@AI Evy [cx-support/extra-prompts] Failed to sync with Retell KB: TypeError: RetellClass is not a constructor at getRetellClient (webpack-internal:///(rsc)/./lib/retell-kb.ts:26:24) at addToRetellKB (webpack-internal:///(rsc)/./lib/retell-kb.ts:61:20) at syncPromptWithRetellKB (webpack-internal:///(rsc)/./lib/retell-kb.ts:129:15) at PATCH (webpack-internal:///(rsc)/./app/api/cx-support/extra-prompts/route.ts:76:97) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async /Users/yassersantiago/Documents/rev_ops_repo/revops-engineering/ops/project-metrics/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:57228
a
Thanks for the follow-up, @YasserSE. I'll get back to you soon.
### Answer --- The
RetellClass is not a constructor
error indicates the SDK module isn't being resolved correctly in your Next.js RSC environment. This is a known bundler/module resolution issue. The correct import and initialization:
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
[(1) ]() , [(2) ]() Key things to try: 1. Add the web shims import before your Retell import if you're in an environment that needs the global web fetch:
Copy code
javascript
import 'retell-sdk/shims/web';
import Retell from 'retell-sdk';
2. Verify Node.js version — the SDK requires Node.js 18.10.0 or higher [(1) ]() 3. The
retell-sdk
is a server-side library
— it should not be used in client-side React code. Ensure your
lib/retell-kb.ts
file is only running in server contexts (which RSC should be, but double-check your bundler config) . [(3) ]() 4. Disable Turbopack if you're using Next.js 15+ with
--turbo
flag, as there are known compatibility issues. If none of these resolve it, the issue may be specific to how your bundler is handling the default export. You could try checking your
tsconfig.json
has
"esModuleInterop": true
and
"moduleResolution": "node"
or
"bundler"
.
​ To learn more, see the sources I considered: [[1] SDKs](https://docs.retellai.com/get-started/sdk) [[2] Retell Node API Library](https://github.com/RetellAI/retell-typescript-sdk/blob/main/README.md) [[3] SDK issue - Can't resolve 'crypto'](https://discord.com/channels/1186424376300679209/1303610599191744575) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
y
@AI Evy Failed to sync with Retell KB: TypeError: retell_sdk__WEBPACK_IMPORTED_MODULE_0___default(...) is not a constructor
a
Thanks for the follow-up, @YasserSE. I'll get back to you soon.
### Answer This error indicates a module resolution issue with how Webpack is handling the default export from
retell-sdk
in your Next.js environment. The correct import syntax is:
Copy code
javascript
import Retell from 'retell-sdk';

const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
[(1) ]() , [(2) ]() Steps to try: 1. Ensure you're using ES module imports — not CommonJS
require()
syntax [(1) ]() 2. Check your Node.js version — the SDK requires Node.js 18.10.0 or higher 3. Verify the package is installed correctly:
Copy code
bash
   npm install retell-sdk
[(2) ]() 4. If using Next.js 15+ with Turbopack, disable Turbopack by running
next dev
without the
--turbo
flag — there are known compatibility issues 5. Check your
tsconfig.json
has
"esModuleInterop": true
— this affects how default exports are handled 6. The SDK is server-side only — ensure your code is running in a server context, not client-side React components If the issue persists after these steps, this may be a bundler-specific configuration problem with how your project resolves ES module default exports. Consider reaching out via [Contact Sales]() or checking [) .
​ To learn more, see the sources I considered: [[1] SDKs](https://docs.retellai.com/get-started/sdk) [[2] Retell Node API Library](https://github.com/RetellAI/retell-typescript-sdk/blob/main/README.md) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.