Error: Couldn't use DynamoDB. tableName has to be set


#1

I am using stages and my current stage is: local
local - webhook, FileDb
dev - lambda, DynamoDb

\config.js (used for defaults including local)
db: {
FileDb: {
pathToFile: ‘…/db/db.json’,
},
},

\config.dev.js
db: {
DynamoDb: {
tableName: ‘${process.env.TABLE_NAME}’,
},
},

\app.js
const { FileDb } = require(‘jovo-db-filedb’);
const { DynamoDb } = require(‘jovo-db-dynamodb’);

app.use(
new Alexa(),
new JovoDebugger(),
new FileDb(),
new DynamoDb(),
new DashbotAlexa(),
new DashbotGoogleAssistant()
);

If I don’t want to use DynamoDB in local stage why is the load function of the plugin even checking for it?

Do I need to add a fake entry in config.js for DynamoDb?
db: {
FileDb: {
pathToFile: ‘…/db/db.json’,
},
DynamoDb: {
tableName: ‘fake’,
},
},


#2

Yes, unfortunately, this doesn’t work as with v1 anymore, since we’re using different modules now that need to be added to the use command. We’re thinking about different ways to make that experience easier, but right now we suggest to do something like this:

app.use(
new Alexa(),
new JovoDebugger(),
new FileDb()
);

if (process.env.STAGE === 'prod') {
    app.use(
        new DynamoDb(),
        new DashbotAlexa(),
        new DashbotGoogleAssistant()
    );
}

#3

How about a common enabled flag for all plugIns defaulted to `true’?

Then I could

\\ config.js
db: {
    FileDb: {
        pathToFile: ‘…/db/db.json’,
    },
    DynamoDb: {
        enabled: false,
    },
},

\\ config.dev.js
db: {
    FileDb: {
        enabled: false,
    },
    DynamoDb: {
        enabled: true, // to override main config
        tableName: ‘${process.env.TABLE_NAME}’
    },
},

#4

Great idea!

I just talked to @AlexSwe about it and he told me that this might already work because all plugins already have an enabled config set to true. This wasn’t intended that way, but might be a good solution.

Would you mind giving this a try in your current setup?


#5

I think you need to update all integrations to include enabled: true and then in the install, exit the method if enabled === false.

Here are my config files:

\\config.js
    db: {
        FileDb: {
            pathToFile: '../db/db.json',
        },
        DynamoDb: {
            enabled: false,
        },        
    },

    analytics: {
        DashbotAlexa: {
            enabled: false,
        },
        DashbotGoogleAssistant: {
            enabled: false,
        },
    },
\\config.dev.js
    db: {
        FileDb: {
            enabled: false,
        },
        DynamoDb: {
            enabled: true,
            tableName: '${process.env.TABLE_NAME}',
        },
    },    
    analytics: {
        DashbotAlexa: {
            enabled: true,
            key: '${process.env.DASHBOT_KEY_ALEXA}',
        },
        DashbotGoogleAssistant: {
            enabled: true,
            key: '${process.env.DASHBOT_KEY_GOOGLE}',
        },
    },

I am using the local stage so only config.js applies at this point, but I wanted you to see how this would play out.

I get the following message from Dashbot:

  YOU MUST SUPPLY AN API_KEY TO DASHBOT!

If I remove the Dashbot integration and just have the FileDb/DynamoDb config,then I get:

Couldn't use DynamoDB. tableName has to be set.

So, integrations are NOT honoring the value of enabled and should be fixed.


#6

Yes, saw that the enabled thing is not ready yet. Will make an update next week.