Dynamic password protection
# đź“–tutorials
Hello everyone! Firstly a lot of thanks to @quick-musician-29561 for helping to build this feature. This function is part of the bigger project I built for Botpress's Hub. The idea is to introduce a password protection feature to your chatbots. However, instead of changing the password via code or expression cards (which can be challenging for people and clients to understand), the aim is to have a dedicated Password Table KB. This way, all you need to do is change your password in the table, which automatically applies to your workflow. Here is how to achieve it: 1) Insert an execute code card and paste the following code: `const dataFromTable = await PasswordTable.findRecords({ filter: AI`everything` }) const password = [] dataFromTable.forEach((originalObject) => { const newObject = { password: originalObject.password } password.push(newObject); }); //console.log("PASSWORD: " + JSON.stringify(password[0].password)) workflow.password = password[0].password` 2) Underneath your code, insert the following two expression cards:
event.payload.text === workflow.password
(this refers to the correct password input)
event.payload.text !== workflow.password
(this refers to the incorrect password input) 3) Create a table and choose your password. In your execute code card, ensure you provide your chosen table name in the first line of the code. In this example, instead of 'PasswordTable'.
const dataFromTable = await PasswordTable.findRecords({
This was a really great idea that will be useful for many bot builders! So THANK YOU for including me in your great project, which is full of useful features 🫡
awesome !
all of us are thinking outside of the box lol
hmm, this seems interesting
deosnt work lol
Hey, Theo, did you change the name of your table within the code?