Registering Custom Content Types and Renderers


#1

Hi, I have created a custom content type and renderer. However when I start the bot it gives below error:

   ERR Error starting botpress:  [Content Manager] Could not register Content Element "customertype.form.js": Unexpected identifier VError: [Content Manager] Could not register Content Element "customertype.form.js": Unexpected identifier
at Object.<anonymous> (D:\Personal\Projects\DemoBotpress\node_modules\botpress\src\content\service.js:574:15)
at Generator.throw (<anonymous>)
at step (D:\Personal\Projects\DemoBotpress\node_modules\botpress\lib\content\service.js:47:202)
at D:\Personal\Projects\DemoBotpress\node_modules\botpress\lib\content\service.js:47:424
at tryCatcher (D:\Personal\Projects\DemoBotpress\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (D:\Personal\Projects\DemoBotpress\node_modules\bluebird\js\release\promise.js:512:31)
at Promise._settlePromise (D:\Personal\Projects\DemoBotpress\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromiseCtx (D:\Personal\Projects\DemoBotpress\node_modules\bluebird\js\release\promise.js:606:10)
at Async._drainQueue (D:\Personal\Projects\DemoBotpress\node_modules\bluebird\js\release\async.js:138:12)
at Async._drainQueues (D:\Personal\Projects\DemoBotpress\node_modules\bluebird\js\release\async.js:143:10)
at Immediate.Async.drainQueues (D:\Personal\Projects\DemoBotpress\node_modules\bluebird\js\release\async.js:17:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)  

Do I need to add/update steps in other scripts?


#2

I believe an error is in content-type definition. Could you post it here?


#3

Please find below Content-Type:

module.exports = {
  id: 'customertype',
  title: 'Customer Type'
  renderer: '#bank-customertype'

  jsonSchema: {
    title: 'Customer Type',
    description: 'Different types of customer using the application i.e. New or Existing',
    type: 'object',
    required: ['customertype'],
    properties:{
      customertype:{
        title: 'Customer Type',
        type: 'array',
        items:{
          type: 'string',
          default: ''
        }
      }
    }
  },

  uiSchema: {
    customertype: {
      'ui:options':{
        orderable: false
      }
    }
  },

  computeData: formData => {
    const customertypechoices = formData.customertype.map(i => ({payload: 'CustomerType', text: i}))
    const choices = [...customertypechoices]

    return {
      choices: choices
    }
  }
}

Please find below content element:

[
  {
    "id": "customertype-U_3sZz",
    "formData": {
      "customertype": [
        "New",
        "Existing"
      ]
    },
    "createdBy": "admin",
    "createdOn": "2018-02-08T18:20:47.638Z"
  }
]

#4

@jainsourabh2, you are missing commas (,) after title: 'Customer Type' and renderer: '#bank-customertype'.


#5

@alex Thanks for your help!! Apologies for missing out on such a trivial issue.


#6

can you tell where we need to create a custom content type and renderer?