Using botkit-cms component in Botkit App
Closed this issue · 6 comments
I have created a chatbot with following steps, which is working fine.
npm install -g botkit
botkit new --platform web
npm install --save botkit-cms
Then, I removed the scripts in the skills folder (except _connection_events.js) & created a new script with code
module.exports = function(controller) {
controller.on('message_received', function(bot, message) {
controller.studio.runTrigger(bot, message.text, message.user, message.channel).catch(function(err) {
bot.reply(message, {text: 'Sorry, I don\'t understand.'});
});
});
};
also, added following code after controller initiation in bot.js
var cms = require('botkit-cms')();
cms.useLocalStudio(controller);
cms.loadScriptsFromFile(__dirname + '/scripts.json').catch(function(err) {
console.error('Error loading scripts', err);`
});
and in the root, copied scripts.json
from cms with basic reply for 'hello' command (same as in sample_scripts.json
).
There's no error, but I'm not getting any response from the bot when I pass 'hello' to chatbot.
What wrong I'm doing?
@peterswimm @benbrown .. I found the issue. The "id" field is missing in the scripts.json created in CMS. Could it be taken as bug & update in Botkit-CMS?
@nayan112 yes! the id field should definitely be included. Ddi you copy the scripts.json file directly from your CMS instance, or did you use the export tool from within the UI?
@benbrown I tried exporting & copying the output within the CMS UI. Both ways, ID is missing.
The next challenge is getting the variable filled with user input & display it for testing purpose. I don't see any documentation or sample code. could you help?
the id
field should definitely be present in the json file created by the CMS. It may be missing from the export.
Regarding variables, you set them in the convo.vars
property during a controller.studio.before
or other handler.