Custom Content Type and Custom Rendering


#1

Hi -
I am new to Botpress.

I just installed the latest version ‘botpress-ce-v11_0_1-win-x64’ of Botpress.
I was going over the documentation and i found some explanation about Content Type, Content Element and Content Rendering. But it is not very clear as to how I can create a custom type and it’s rendering.

Also reading further in the section ‘Creating Modules’ it says:
“and soon they will be able to add new content types and content elements”.

so, I am not able to clearly understand how can i create custom content type and it’s rendering that is specific to my domain.

I am trying to understand if I have to add custom elements like Radio Buttons or Checkboxes or Dropdowns in my response that is displayed in the web chat for instance, how can i achieve that.

I would highly appreciate if someone can provide some example or link to the documentation.

Thanks in advance.


#2

This is the main problem here in Botpress. Even I wanted to achieve the same but the documentation is very pathetic.

Sorry Botpress guys for being very honest to your face. I’m sure you guys did a great job in creating this but lack of user friendly documentation makes is look very low class. I had tried V11 but it breaks when I use Carousel.

Too bad! I hope you guys take this serious and start writing some quality, user friendly documentation with well written example codes.

Cheers,
Neeraj


#3

v11 isn’t stable yet. I’d recommend you to use v10 and relevant documentation.


#4

hi Alex, thanks for your reply.
quick follow up question around this.
can i use the v11 and still follow v10 documentation to create custom type, rendering or they are incompatible. also can you point to the v10 documentation that describes how i can create custom response messages with elements like checkbox, radio buttons etc.


#5

v10 isn’t compatible with v11, so this wouldn’t work.

Creating custom elements in the webchat is possible via webchat-extensions.


#6

Hey @alex im following the recipe webchat-extensions but im getting an error try to compile it.

    ERROR in ./src/index.js
    Module build failed: SyntaxError: Unexpected token (17:10)

      15 |   };
      16 |
    > 17 |   return (<select onChange={handleChange}>
         |           ^
      18 |     {(slots || []).map((slot, i) => (
      19 |         <option value={slot} key={i}>
      20 |           {slot}

I think im not adding the react component correctly. Is it possible you share how the index.js file should look like?


#7

I figured out the issue! I was putting the react component in the wrong index.js file. Now I compiled and linked the plugin try to use it but im getting the following in emulator:
image

This is my function which I invoke to use the new content type:

/**
 * Use botpress-webchat-plugin-select type
 */
async function webChatSelect(state, event) {
var data = [1,2,3];
    event.reply('#select', {text: 'Select option',type: '@botpress/botpress-webchat-plugin-select',data: { slots: data.slots }})
}

Any idea why im getting the error?


#8

update!

Error went away after pointing type to full path of module. Now I only get the text without the drop-down menu.

'#select': data => ({
        text: 'Select option',
        type: 'modules/botpress-webchat-plugin-select',
        data: { slots: data.slots }
        })

image

Also, in browser console I see this error:

Error rendering plugin Error: Subview "Entry" doesn't exist for module
"webchat-plugin-select"

@banoresaurabh did you try this plugin before? Can you help me understand why its not working properly? Im kinda of in a time crunch :frowning:


#9

Do you have smth like export const Entry = () => null; as in example?


#10

@Haythamamin Can you share your code in module i am trying to do the same but it does not work