Sklaiivy
Sklaiivy2d ago

Add "canEdit" : true to Text files import via API to the knowledgebase

Is there a way to add Text files via API to the knowledgebase but with the feature "canEdit" : true ?
2 Replies
NiKo | Voiceflow
Hi @Sklaiivy I haven’t tested it in a while, but you should be able to do it with something like this:
async function executePostRequest(
filename: string,
doc: string,
apiKey: string,
projectID: string,
log: Log,
) {
let form = new FormData();

form.append("file", doc, { filename: filename });
form.append("canEdit", "true");

let request = {
method: "post",
url: `https://api.voiceflow.com/v3/projects/${projectID}/knowledge-base/documents/file`,
headers: {
accept: "application/json, text/plain, */*",
"content-type": `multipart/form-data; boundary=${form.getBoundary()}`,
authorization: apiKey,
...form.getHeaders(),
},
data: form,
};

return axios(request)
.then(function (response) {
//console.log(JSON.stringify(response.data))
log.info(`Uploading ${filename} to KB | ${response.data.status.type}`);
return;
})
.catch(function (error) {
console.log(error);
return;
});
}
async function executePostRequest(
filename: string,
doc: string,
apiKey: string,
projectID: string,
log: Log,
) {
let form = new FormData();

form.append("file", doc, { filename: filename });
form.append("canEdit", "true");

let request = {
method: "post",
url: `https://api.voiceflow.com/v3/projects/${projectID}/knowledge-base/documents/file`,
headers: {
accept: "application/json, text/plain, */*",
"content-type": `multipart/form-data; boundary=${form.getBoundary()}`,
authorization: apiKey,
...form.getHeaders(),
},
data: form,
};

return axios(request)
.then(function (response) {
//console.log(JSON.stringify(response.data))
log.info(`Uploading ${filename} to KB | ${response.data.status.type}`);
return;
})
.catch(function (error) {
console.log(error);
return;
});
}
https://github.com/voiceflow-community/vf-crawler-uploader
GitHub
GitHub - voiceflow-community/vf-crawler-uploader: Crawl a site to g...
Crawl a site to generate knowledge files and upload them to your KB - voiceflow-community/vf-crawler-uploader
Sklaiivy
SklaiivyOP2d ago
Hi @NiKo | Voiceflow Thanks, but I figured it out with the cURL !

Did you find this page helpful?