mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 23:01:09 +03:00
add a public endpoint to retrieve chatbotconfig
This commit is contained in:
@@ -138,6 +138,7 @@ export class App {
|
|||||||
'/api/v1/verify/apikey/',
|
'/api/v1/verify/apikey/',
|
||||||
'/api/v1/chatflows/apikey/',
|
'/api/v1/chatflows/apikey/',
|
||||||
'/api/v1/public-chatflows',
|
'/api/v1/public-chatflows',
|
||||||
|
'/api/v1/public-chatbotConfig',
|
||||||
'/api/v1/prediction/',
|
'/api/v1/prediction/',
|
||||||
'/api/v1/vector/upsert/',
|
'/api/v1/vector/upsert/',
|
||||||
'/api/v1/node-icon/',
|
'/api/v1/node-icon/',
|
||||||
@@ -328,6 +329,23 @@ export class App {
|
|||||||
return res.status(404).send(`Chatflow ${req.params.id} not found`)
|
return res.status(404).send(`Chatflow ${req.params.id} not found`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Get specific chatflow chatbotConfig via id (PUBLIC endpoint, used to retrieve config for embedded chat)
|
||||||
|
// Safe as public endpoint as chatbotConfig doesn't contain sensitive credential
|
||||||
|
this.app.get('/api/v1/public-chatbotConfig/:id', async (req: Request, res: Response) => {
|
||||||
|
const chatflow = await this.AppDataSource.getRepository(ChatFlow).findOneBy({
|
||||||
|
id: req.params.id
|
||||||
|
})
|
||||||
|
if (chatflow && chatflow.chatbotConfig) {
|
||||||
|
try {
|
||||||
|
const parsedConfig = JSON.parse(chatflow.chatbotConfig)
|
||||||
|
return res.json(parsedConfig)
|
||||||
|
} catch (e) {
|
||||||
|
return res.status(500).send(`Error parsing Chatbot Config for Chatflow ${req.params.id}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res.status(404).send(`Chatbot Config for Chatflow ${req.params.id} not found`)
|
||||||
|
})
|
||||||
|
|
||||||
// Save chatflow
|
// Save chatflow
|
||||||
this.app.post('/api/v1/chatflows', async (req: Request, res: Response) => {
|
this.app.post('/api/v1/chatflows', async (req: Request, res: Response) => {
|
||||||
const body = req.body
|
const body = req.body
|
||||||
|
|||||||
Reference in New Issue
Block a user