"use strict";(self.webpackChunknewoaks_help=self.webpackChunknewoaks_help||[]).push([[1960],{9963:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>l,contentTitle:()=>h,default:()=>p,frontMatter:()=>d,metadata:()=>s,toc:()=>c});const s=JSON.parse('{"id":"api/chatbot/knowledge/get-chatbot-knowledge","title":"Get Chatbot Knowledge Base","description":"The  API enables the retrieval of knowledge base data for a specified chatbot by sending a POST request to the /chat/Chatbot/GetSource endpoint.","source":"@site/developer/api/002.chatbot/002.knowledge/103.get-chatbot-knowledge.md","sourceDirName":"api/002.chatbot/002.knowledge","slug":"/api/chatbot/knowledge/get-chatbot-knowledge","permalink":"/guides/developer/api/chatbot/knowledge/get-chatbot-knowledge","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":1,"frontMatter":{"sidebar_position":1},"sidebar":"sidebar","previous":{"title":"Knowledge Base","permalink":"/guides/developer/category/knowledge-base"},"next":{"title":"Edit Chatbot Knowledge Base","permalink":"/guides/developer/api/chatbot/knowledge/edit-chatbot-knowledge"}}');var a=n(4848),r=n(8453),o=n(767),i=n(8175);const d={sidebar_position:1},h="Get Chatbot Knowledge Base",l={},c=[{value:"Endpoint",id:"endpoint",level:2},{value:"Request Headers",id:"request-headers",level:2},{value:"Request Body",id:"request-body",level:2},{value:"Example Request",id:"example-request",level:2},{value:"Response",id:"response",level:2},{value:"Error Handling",id:"error-handling",level:2}];function u(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",p:"p",...(0,r.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.header,{children:(0,a.jsx)(t.h1,{id:"get-chatbot-knowledge-base",children:"Get Chatbot Knowledge Base"})}),"\n",(0,a.jsxs)(t.p,{children:["The ",(0,a.jsx)(i.A,{})," API enables the retrieval of knowledge base data for a specified chatbot by sending a ",(0,a.jsx)(t.code,{children:"POST"})," request to the ",(0,a.jsx)(t.code,{children:"/chat/Chatbot/GetSource"})," endpoint."]}),"\n",(0,a.jsx)(t.h2,{id:"endpoint",children:"Endpoint"}),"\n",(0,a.jsx)(o.TM,{path:"/chat/Chatbot/GetSource"}),"\n",(0,a.jsx)(t.h2,{id:"request-headers",children:"Request Headers"}),"\n",(0,a.jsx)(o.iW,{}),"\n",(0,a.jsx)(t.h2,{id:"request-body",children:"Request Body"}),"\n",(0,a.jsx)(o.VQ,{requestBody:{serialNumber:"3254a9d0424c4806b9ea3d0763xxxxxx"},requestBodyParams:{serialNumber:"string, required - The unique identifier (ID) of the chatbot"}}),"\n",(0,a.jsx)(t.h2,{id:"example-request",children:"Example Request"}),"\n",(0,a.jsx)(o.r3,{path:"/chat/Chatbot/GetSource",requestBody:{serialNumber:"3254a9d0424c4806b9ea3d0763xxxxxx"}}),"\n",(0,a.jsx)(t.h2,{id:"response",children:"Response"}),"\n",(0,a.jsx)(o.zV,{responseExample:{Data:[{Type:"FileList",Name:"34321",Value:"FAQ_0403.txt",Length:12043,Status:2,StatusMessage:"Succeeded",ID:377631,SourceLink:""},{Type:"CompanyInfo",Name:"CompanyInfo",Value:"",Length:286,Status:2,StatusMessage:"Succeeded",ID:377634,SourceLink:""},{Type:"UrlList",Name:"www.example.com",Value:"",Length:0,Status:3,StatusMessage:"Failed",ID:377635,SourceLink:"www.example.com"},{Type:"Text",Name:"111111111",Value:"",Length:9,Status:2,StatusMessage:"Succeeded",ID:377636,SourceLink:""},{Type:"QAList",Name:"Question",Value:"Answer",Length:9,Status:2,StatusMessage:"Succeeded",ID:377627,SourceLink:""}]},responseComments:{Data:"array - List of knowledge items","Data[].Type":"string - Type of knowledge (FileList, CompanyInfo, UrlList, Text, QAList)","Data[].Name":"string - Name or ID of the item","Data[].Value":"string - Value or filename","Data[].Length":"integer - Content length","Data[].Status":"integer - Training status (0: Not Started, 1: InTraining, 2: Success, 3: Failed)","Data[].StatusMessage":"string - Status description","Data[].ID":"integer - Unique identifier of the knowledge item","Data[].SourceLink":"string - Source URL for UrlList type"}}),"\n",(0,a.jsx)(t.h2,{id:"error-handling",children:"Error Handling"}),"\n",(0,a.jsx)(o.NH,{})]})}function p(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(u,{...e})}):u(e)}},767:(e,t,n)=>{n.d(t,{Ay:()=>g,NH:()=>p,TM:()=>d,VQ:()=>l,iW:()=>h,r3:()=>c,zV:()=>u});n(6540);var s=n(3532),a=n(8069),r=n(9303),o=n(4848);const i=function(e,t){void 0===t&&(t={});const n=JSON.stringify(e,null,2).split("\n"),s=[];return n.forEach((e=>{const n=e.match(/"([^"]+)":/);if(n&&t[n[1]]){const a=e.match(/^\s*/)?.[0]||"";s.push(`${a}// ${t[n[1]]}`)}s.push(e)})),s.join("\n")},d=e=>{let{path:t,method:n="POST"}=e;const a=(0,s.r)()(t)||`https://usapi.hottask.com${t}`;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("p",{children:[(0,o.jsx)("strong",{children:"Request URL:"})," ",a]}),(0,o.jsxs)("p",{children:[(0,o.jsx)("strong",{children:"Method:"})," ",n]})]})},h=e=>{let{headers:t={Authorization:"<Your-Secret-Key>","Content-Type":"application/json"},headersDescription:n={Authorization:"string, required - The secret key for authenticating the API request","Content-Type":"string, required - The content type of the request payload (must be application/json)"}}=e;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:"The API request must include the following headers:"}),(0,o.jsx)("ul",{children:Object.entries(t).map((e=>{let[t,s]=e;return(0,o.jsxs)("li",{children:[(0,o.jsxs)("code",{children:[t,": ",s]})," - ",n[t]]},t)}))})]})},l=e=>{let{requestBody:t,requestBodyParams:n,addCommentsToJson:s=i}=e;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:"The request body should contain the following parameters:"}),(0,o.jsx)(a.A,{language:"json",children:s(t,n)}),(0,o.jsx)("ul",{children:Object.entries(n).map((e=>{let[t,n]=e;return(0,o.jsxs)("li",{children:[(0,o.jsx)("code",{children:t})," - ",n]},t)}))})]})},c=e=>{let{method:t="POST",path:n,requestBody:i,headers:d={Authorization:"<Your-Secret-Key>","Content-Type":"application/json"}}=e;const h=(0,s.r)()(n),l="undefined"==typeof window?"usapi.hottask.com":new URL(h||`https://usapi.hottask.com${n}`).host,c={javascript:`const res = await fetch('${h||`https://usapi.hottask.com${n}`}', {\n  method: '${t}',\n  headers: ${JSON.stringify(d,null,2)},\n  body: JSON.stringify(${JSON.stringify(i,null,2)})\n});\n\nconst data = await res.json();\nconsole.log(data);`,python:`import requests\nimport json\n\nurl = '${h||`https://usapi.hottask.com${n}`}'\nheaders = ${JSON.stringify(d,null,4)}\ndata = ${JSON.stringify(i,null,2)}\n\nresponse = requests.${t.toLowerCase()}(url, headers=headers, json=data)\ndata = response.json()\nprint(data)`,bash:`curl '${h||`https://usapi.hottask.com${n}`}' \\\n  -X ${t} \\\n${Object.entries(d).map((e=>{let[t,n]=e;return`  -H '${t}: ${n}' \\`})).join("\n")}\n  -d '${JSON.stringify(i)}'`,http:`${t} ${n} HTTP/1.1\nHost: ${l}\n${Object.entries(d).map((e=>{let[t,n]=e;return`${t}: ${n}`})).join("\n")}\n\n${JSON.stringify(i,null,2)}`};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r.A,{as:"h3",children:"JavaScript (Fetch API)"}),(0,o.jsx)(a.A,{language:"javascript",children:c.javascript}),(0,o.jsx)(r.A,{as:"h3",children:"Python (Requests Library)"}),(0,o.jsx)(a.A,{language:"python",children:c.python}),(0,o.jsx)(r.A,{as:"h3",children:"cURL"}),(0,o.jsx)(a.A,{language:"bash",children:c.bash}),(0,o.jsx)(r.A,{as:"h3",children:"HTTP Request"}),(0,o.jsx)(a.A,{language:"http",children:c.http})]})},u=e=>{let{responseExample:t,responseComments:n,addCommentsToJson:s=i}=e;const r={...t,Version:"1.0.0",Success:!0,Code:200,Message:""},d={...n,Version:"string - API version",Success:"boolean - Operation success status",Code:"integer - HTTP status code",Message:"string - Error message if any"};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("p",{children:"The API response will be a JSON object with the following structure:"}),(0,o.jsx)(a.A,{language:"json",children:s(r,d)})]})},p=e=>{let{errorHandling:t="If the request fails, you should:\n1. Check the HTTP status code for network-level errors\n2. Examine the `Code` and `Message` fields in the response for business-level errors\n3. The `Message` field will contain detailed error information"}=e;return(0,o.jsx)("div",{style:{whiteSpace:"pre-line"},children:t})};function g(e){let{title:t,path:n,method:a="POST",description:r="",requestBody:g={timeZone:"Asia/Shanghai",type:0},requestBodyDescription:m={timeZone:"The time zone of the chatbot. The standard time zone format: e.g., Asia/Shanghai or America/New_York.",type:"Create a generic chatbot with a fixed value of 0"},requestBodyComments:x={timeZone:"string, required",type:"integer, required"},responseExample:j={Data:"3254a9d0424c4806b9ea3d0763xxxxxx",Version:"1.0.0",Success:!0,Code:200,Message:""},responseComments:f={Data:"chatbot id"},headers:w={Authorization:"<Your-Secret-Key>","Content-Type":"application/json"},headersDescription:y={Authorization:"The secret key for authenticating the API request.","Content-Type":"The content type of the request payload."},errorHandling:b="If it's an HTTP network error, you should check the `HTTP status code`. If it's a business exception, you need to examine the `Code` and `Message` fields, which will provide the error details."}=e;const S=(0,s.r)()(n),k="undefined"==typeof window?"usapi.hottask.com":new URL(S||`https://usapi.hottask.com${n}`).host;JSON.stringify(w,null,2),i(g,x),JSON.stringify(w,null,4),i(g,x),a.toLowerCase(),Object.entries(w).map((e=>{let[t,n]=e;return`  -H '${t}: ${n}' \\`})).join("\n"),JSON.stringify(g),Object.entries(w).map((e=>{let[t,n]=e;return`${t}: ${n}`})).join("\n"),i(g,x);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(d,{path:n,method:a}),(0,o.jsx)(h,{headers:w,headersDescription:y}),(0,o.jsx)(l,{requestBody:g,requestBodyParams:m,addCommentsToJson:i}),(0,o.jsx)(c,{method:a,path:n,requestBody:g,headers:w}),(0,o.jsx)(u,{responseExample:j,responseComments:f,addCommentsToJson:i}),(0,o.jsx)(p,{errorHandling:b})]})}},8175:(e,t,n)=>{n.d(t,{A:()=>r});n(6540);var s=n(5872),a=n(4848);function r(){let e=(0,s.K)()();return["newoaks.ai","www.newoaks.ai","eu.newoaks.ai"].includes(e)&&(e="NewOaks AI"),"appointify.ai"===e&&(e="Appointify AI"),(0,a.jsx)("code",{children:e})}},3532:(e,t,n)=>{function s(){return function(e){if("undefined"==typeof window)return"";const t=window.location.hostname;let n="";return n="www.newoaks.ai"==t||"newoaks.ai"==t?"https://usapi.hottask.com":"eu.newoaks.ai"==t?"https://euapi.hottask.com":`https://${t}`,e?`${n}${e.startsWith("/")?e:`/${e}`}`:n}}n.d(t,{r:()=>s})},5872:(e,t,n)=>{function s(){return function(){return"undefined"==typeof window?"":window.location.hostname}}n.d(t,{K:()=>s})}}]);