Create a data table with code
# 🤝help
q
Hello, I'm looking to create a code that will automatically create a data table. I have looked at the botpress documentataion but I don't understand it. I'm simply looking to create a data table called "Table2" with a single column called "Need".
f
Would you like to create this in Botpress or outside of Botpress?
q
@fresh-fireman-491 In Botpress
f
You can use the Botpress client.
But why would you like to do it via code?
And not just create one manually
q
Ok. Because I want the table to be created when I take a particular action in my conversation with the chatbot and then to put information in it. How do I do this with Botpress Client?
@fresh-fireman-491 Ok. Because I want the table to be created when I take a particular action in my conversation with the chatbot and then to put information in it. How do I do this with Botpress Client?
f
q
@fresh-fireman-491 Perfect, thank you. This is what I found too but I don't know what to replace in it so that it creates a data table with a column.
f
You would use an execute code card for this
q
@fresh-fireman-491 Yes I know but what to change in this code knowing that I just want to create a data table named "Table2" with a single column named "Need": "const { table } = await client.createTable({ name: 'Data1Table', schema: { type: 'object', x-zui': {}, properties: { name: { type: 'string', x-zui': { index: 0, searchable: true }, nullable: true } }, additionalProperties: true } })"
f
Maybe something like this.
Copy code
javascript
const { table } = await client.createTable({
  name: '2Table',
  schema: {
    name: 'Need'
  }
})
Going back to do school work, but if that doesn't work I can try later today
q
perfect thanks
f
But let me know if that worked for you
11 Views