Add option to create a code library
# 👀feature-requests
w
I enjoy very much the "execute code" feature, but I think it is hard to scale, because I have to copy the same code multiple times in different cards. A very useful feature would be a place in which you can write code that can be reused in other cards. An implementation suggestion is the creation of an icon that would create a library file in the UI, something similar to create a workflow, table or KB. This would allow for easy code review, and would lead to better code quality.
h
I imagine this would take a lot of work to implement so won;t be a high priority but I really love the idea! An awesome way to further the no-code approach of Botpress.
c
this sounds like a pretty useful idea. Maybe there can be a "bucket" next to the code editor/below the variables tab where you can keep tabs of functions/code snippets. I really dislike the execute code though.. it is not intuitive, does not allow for undo/redo, hard to read, no collapsible code (!). Rather I recommend to create your own VSCode folder containing functions you want to re-use. Oldskool but it works 😛
w
@cold-jewelry-54343 great suggestion! I am used to developing code with git, and working with Botpress makes me a little afraid of losing code, or releasing buggy stuff. How do you keep your VSCode in sync with Botpress? I think you need the discipline of only coding in VSCode and never do it in botpress, then yout copy and paste things in Botpress, right?
l
To avoid code duplication, we put functions into separate workflows. And you can use workflow or session variables as variables for these functions. The only caveat is that these are limited to individual bots. Having some workspace-wide flows/variables/functions would be useful.