Giter VIP home page Giter VIP logo

botkit-cms's Introduction

Botkit CMS

An open tool for designing, building and managing interactive dialog systems

Dialog Editor

Install and run it locally

Clone and install botkit-cms

git clone https://github.com/howdyai/botkit-cms.git
cd botkit-cms
npm install

Create an .env file from .env_sample and change the variables

cp .env_sample .env
PLATFORM=web
TOKENS=youwillneverguessmysecretbottoken
USERS=admin:123secret

Create .data folder, create a scripts.json inside. Copy the content from sample-scripts.json

mkdir .data
cp sample_scripts.json .data/scripts.json

Run cms and open localhost:3000/admin and enter the credentials from the USERS env variable.

npm run build
npm start

Create Botkit Dialog Editor & API Service

Clone this repo and set it up on a public host somewhere. Clicking the Glitch link below will do this for you.

Configure the .env file.

Launch the app, then load it in your web browser. You should see a link to the editor screen.

Make sure your new service is available at a public address on the web. Then, modify your Botkit app to include a pointer to this new service.

var controller = Botkit.platform({
  studio_command_uri: 'https://my.new.service',
  studio_token: 'a shared secret'
})

Remix on Glitch

Configuration

Options for this service are controlled via environment variables, which can be stored in a .env file at the project root.

Here is an example .env file:

# Chat platform
# PLATFORM=<platform>
# valid options are slack, teams, ciscospark, web, facebook
PLATFORM=slack

# authentication tokens for Bot users
# TOKENS="123 456"
TOKENS=youwillneverguessmysecretbottoken

# Admin users for UI
# USERS="username:password username2:password2 username3:password3"
USERS=admin:123secret

# LUIS Endpoint
# URL to published LUIS Endpoint in the form of https://<REGION>.api.cognitive.microsoft.com/luis/v2.0/apps/<APPID>?subscription-key=<SUBID>&verbose=true&timezoneOffset=-360&q=
# Get this from LUIS.ai Keys and Endpoint settings
# LUIS_ENDPOINT=

# LUIS App Version
# Defaults to 0.1, update if you manage multiple LUIS app versions
# LUIS_VERSION=0.1

Using LUIS.ai

This project includes support for using LUIS.ai to determine the intent represented by an incoming message. To enable LUIS, add the LUIS_ENDPOINT variable to your environment.

After enabling LUIS, new options will appear in the Trigger dialog that will allow you to assign intents from LUIS as triggers.

Editor Configuration

The Botkit dialog editor can be used in one of several different flavors, controlled by the PLATFORM environment variable.

Value Description
web Botkit Anywhere mode
slack Slack mode
teams Microsoft Teams mode
ciscospark Cisco Spark / Webex Teams mode
facebook Facebook mode

Securing Admin / Editor Access

Access can be limited and users can be controlled using the USERS environment variable.

Set the variable to a space separated list of user:password pairs. Users will be shown a login prompt when accessing any url within the /admin/ url.

Securing API Access

You can lock down access to the API by specifying one or more access tokens in the TOKENS environment variable (or in the .env file).

If any tokens are specified, access to the API requies a valid value in the access_token url query parameter. Botkit will automatically use the Botkit Studio studio_token value for this.

Building Project

Modifications to the front end application or css should be done to their original source files, then compiled by the build process. To build the Javascript and CSS files from their source locations, run the following command:

npm run build

The front end editor application included in this project is built with Angular. The source code of the this application is broken up into several component files in the js/ folder. These are compiled into a single source file and moved to a final home at public/js/scripts.js by the build process.

The CSS is controlled by SASS files in the sass/ folder. These are compiled into a single source file and moved to a final home at public/css/new.css by the build process.

Alternate: Use this as a component in your Botkit App

First, npm install this:

npm install --save botkit-cms

Get your existing scripts from an instance of Botkit CMS, and put the resulting scripts.json into your bot project.

Then, add to your bot's main file, just after defining your controller object:

var cms = require('botkit-cms')();
cms.useLocalStudio(controller);

cms.loadScriptsFromFile(__dirname + '/scripts.json').catch(function(err) {
  console.error('Error loading scripts', err);
});

Note that you might need to modify the call to cms.loadScriptsFromFile depending on where you put the scripts.json file.

botkit-cms's People

Contributors

benbrown avatar dependabot[bot] avatar peterswimm avatar tamalchowdhury avatar vicky002 avatar vitogit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

botkit-cms's Issues

Trying to get in touch regarding a security issue

Hey there!

I'd like to report a security issue but cannot find contact instructions on your repository.

If not a hassle, might you kindly add a SECURITY.md file with an email, or another contact method? GitHub recommends this best practice to ensure security issues are responsibly disclosed, and it would serve as a simple instruction for security researchers in the future.

Thank you for your consideration, and I look forward to hearing from you!

(cc @huntr-helper)

Using botkit-cms component in Botkit App

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?

Persistent storage other than file system?

I have a use case to share persistent storage across multiple instances of botkit-cms which excludes file system.

What would be the best approach to have persistent storage shared across multiple instances of botkit-cms?

Missing documentation for adding calls to CMS to starter kits

We should add documentation about making calls to controller.studio.runTrigger.

The following code should be added to the bot.js file, in addition to configuring the controller with the studio_command_url parameter:

// This captures and evaluates any message sent to the bot as a DM
// or sent to the bot in the form "@bot message" and passes it to
// Botkit Studio to evaluate for trigger words and patterns.
// If a trigger is matched, the conversation will automatically fire!
// You can tie into the execution of the script using the functions
// controller.studio.before, controller.studio.after and controller.studio.validate
if (process.env.studio_token) {
    controller.on('message_received', function(bot, message) {
        controller.studio.runTrigger(bot, message.text, message.user, message.channel, message).then(function(convo) {
            if (!convo) {
              // web bot requires a response of some kind!
              bot.reply(message,'OK');

                // no trigger was matched
                // If you want your bot to respond to every message,
                // define a 'fallback' script in Botkit Studio
                // and uncomment the line below.
                // controller.studio.run(bot, 'fallback', message.user, message.channel, message);
            } else {
                // set variables here that are needed for EVERY script
                // use controller.studio.before('script') to set variables specific to a script
                convo.setVar('current_time', new Date());
                convo.setVar('bot', controller.studio_identity);
            }
        }).catch(function(err) {
            bot.reply(message, 'I experienced an error with a request to Botkit Studio: ' + err);
            debug('Botkit Studio: ', err);
        });
    });
} else {

    console.log('~~~~~~~~~~');
    console.log('NOTE: Botkit Studio functionality has not been enabled');
    console.log('To enable, pass in a studio_token parameter with a token from https://studio.botkit.ai/');
}```

Issue using botkit cms locally within botkit

Hey,

I am trying to get botkit-cms working locally within a botkit app. I think this would be ideal for a production deployment, not having to rely on another server to be up.

I am using

"botkit": "^4.0.2",
"botkit-cms": "0.0.4",
"botkit-plugin-cms": "^1.0.1",

When I follow the directions and include:

var cms = require('botkit-cms')();
cms.useLocalStudio(controller);

cms.loadScriptsFromFile(__dirname + '/scripts.json').catch(function(err) {
  console.error('Error loading scripts', err);
});

I get the following error: TypeError: Cannot set property 'evaluateTrigger' of undefined.

I fixed here this by changing the controller.studio references to be controller.plugins.cms. This seems to fix the problem and things seem to more or less work. The bot responds to the triggers that are setup.

However, there is an exception when the input is something that doesn't cause any triggers to be returned.

Error in trigger handler undefined
(node:53014) UnhandledPromiseRejectionWarning: Error:
  at Botkit.<anonymous> (blah/blah/node_modules/botkit/src/core.ts:1036:27)

Thanks for any help or direction on how to continue looking into this.

Condition go_to_thread in botkit-cms

Hello,

How can I modify botkit-cms and add a new the possibility to go to a thread using conditions (Facebook Messenger bot). I know that we can do it using a text box by "collecting data" from user. But I want to be able to do as a simple if condition.

Here is an exemple:
Sélection_249

Thank you.

`controller.studio.runTrigger` should resolve promise regardless of whether a trigger was matched

While working with the cms locally, using useLocalStudio = true, evaluateTrigger doesn't exactly behave the way it should. In the case where no trigger was matched, the promise is rejected (which it should resolve to mimic the functionality of CMS run as remote API service)

reject();

When run as an API service, evaluateTrigger always resolves, even when there was no match. This in turn affects the Promise object returned by runTrigger

Also have a look at howdyai/botkit@ef69730

Issues in triggering Conditional Actions

I have two conditions: yes or no. If yes trigger action 2, if no trigger action 6. Only one action works whichever is added as a first condition.
My sample json is:

{
"pattern": "no",
"type": "utterance",
"action": "6"
},
{
"pattern": "yes",
"type": "utterance",
"action": "2"
}

Sync between Botkit & Botkit-CMS

Hi,
I have botkit and botkit-cms on the same server, both of them are running and everything fine.

I added the following to .env file (on botkit) and configured the .env on botkit-cms.
var controller = Botkit.web({
studio_command_uri: 'http://MyIP:3000',
studio_token: 'blablablabla',
});

##Chat platform
PLATFORM=web
##authentication tokens for Bot users
TOKENS=blablablabla
##Admin users for UI
USERS=admin:mypass

I added some text into the CMS framework and when I am checking the bot after the amendments in the CMS, nothing happens.
It looks like that something is not connected well, how to connect them? how to check that they are talking to each other?

Thanks a lot

A dialog with an id of 'hello:botkit-wrapper' wasn't found.

Hi,

I am using botkit and have setup botkit-cms version 0.0.3 running locally. I added a new dialog named hello and saved it with the defaults. When I type hello into slack there is an error:

A dialog with an id of 'hello:botkit-wrapper' wasn't found.

I am using:

    "botbuilder-adapter-slack": "^1.0.2",
    "botkit": "^4.0.1",
    "botkit-plugin-cms": "^1.0.0"

I am not sure if its caused by the way botkit-cms writes the script file or if its the way the botkit/botworker reads the file. If I remove id + ':botkit-wrapper' from the botkit/botworker beginDialog code the hello dialog executes fine.

Am I missing something simple?

Thanks!

Multiple instances of botkit-cms - storage in database?

Hi,

I have a use case to write multiple instances of botkit-cms and can't see a way to do it because the storage is on the file system(?) or in-memory?

Is there any way to have botkit-cms store the scripts in a database?

NPM and package.json "versions" Sync

Hello,

Thanks immensely to this wonderful piece of software. It rocks!

It appears the npm version of botkit-cms (0.0.4, at this time) is ahead of the version specified in the package.json file (0.0.3, at this time).

Some suggestions:

  1. commits, released to npm, be tagged (with their respective npm versions).
  2. the package.json's version be updated to reflect the version in 1 above.

This will make it easier to update live botkit-cms servers to specific versions, as the case may be.

Thanks, once again.

Warm regards, please.

Adebisi, FA.

Intents only for triggers?

Hello!

I've created a model with a few intents and have it connected to botkit-cms, and then my bot connected to that. So far everything seems to function as expected. When configuring scripts and their associated triggers, I can select the intents from my model and things work great.

Once inside a script, is there also a way to have the conditional actions use my model's intents to choose what to do? So instead of exact/regex matching, use the model intent prediction like the trigger mechanism?

Thanks!

npm install Error

When I run npm install after clone the git repository, I get the next error message on the log file that was created:

7839 verbose stack Error: [email protected] postinstall: node scripts/build.js
7839 verbose stack Exit status 1
7839 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
7839 verbose stack at EventEmitter.emit (events.js:311:20)
7839 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
7839 verbose stack at ChildProcess.emit (events.js:311:20)
7839 verbose stack at maybeClose (internal/child_process.js:1021:16)
7839 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
7840 verbose pkgid [email protected]
7841 verbose cwd /home/user/Proyects/botkit-cms
7842 verbose Linux 4.15.0-65-generic
7843 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
7844 verbose node v12.16.1
7845 verbose npm v6.13.4
7846 error code ELIFECYCLE
7847 error errno 1
7848 error [email protected] postinstall: node scripts/build.js
7848 error Exit status 1
7849 error Failed at the [email protected] postinstall script.
7849 error This is probably not a problem with npm. There is likely additional logging output above.
7850 verbose exit [ 1, true ]

My Configuration:
npm -v
6.13.4

node -v
v12.16.1

Ubuntu LTS 18.04

Any one can help me whats going on?
Regards,
Francisco Yu

Is a variation of doesn't seem to work

Hey,

I have a simple script configured to say yes or no based on the condition if is variation of
Screen Shot 2019-05-22 at 7 48 03 PM

However, it never seems to branch to the no condition.

Screen Shot 2019-05-22 at 7 49 07 PM

I am using the following:

 "botbuilder-adapter-slack": "^1.0.2",
"botbuilder-storage-mongodb": "^0.9.5",
"botkit": "^4.0.2",
"botkit-plugin-cms": "^1.0.1"

And botkit-cms version 0.0.3

Is there a config I am missing? Thanks!

error when "npm start"

Hi
I got this error when I try get the cms up and running;

`root@3b74527adc70:/app# npm start

[email protected] start /app
node index.js

internal/modules/cjs/loader.js:796
throw err;
^

Error: Cannot find module '/app/src/api.js'
Require stack:

  • /app/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/app/index.js:2:11)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [ '/app/index.js' ]
    }
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! [email protected] start: node index.js
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the [email protected] start script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-03-02T16_33_07_062Z-debug.log
`

Before that, "npm run build" was successful like this;

`root@3b74527adc70:/app# npm run build

[email protected] build /app
./node_modules/gulp/bin/gulp.js

[16:32:09] Using gulpfile /app/gulpfile.js
[16:32:09] Starting 'default'...
[16:32:09] Starting 'controller-concat'...
[16:32:09] Concatenating and Copying Controllers...
[16:32:10] Finished 'controller-concat' after 26 ms
[16:32:10] Starting 'copy-partials'...
[16:32:10] Copying HTML partials...
[16:32:10] Finished 'copy-partials' after 7.53 ms
[16:32:10] Starting 'copy-more-partials'...
[16:32:10] Copying HTML partials...
[16:32:10] Finished 'copy-more-partials' after 4.99 ms
[16:32:10] Starting 'sass'...
[16:32:10] Compiling Sass...
[16:32:10] Finished 'sass' after 5.73 ms
[16:32:10] Finished 'default' after 47 ms
`

Any idea?
Thank you in advance!

Install fails with new Apple Silicon (Node Sass does not yet support your current environment)

After completing the steps in the README, I ran "npm run build".

This step returned the error below on the new Apple silicon. The expected result was a successful build.

Error: Node Sass does not yet support your current environment: OS X Unsupported architecture (arm64) with Unsupported runtime (88)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.9.4

Model Name: MacBook Pro
Model Identifier: MacBookPro17,1
Chip: Apple M1
Total Number of Cores: 8 (4 performance and 4 efficiency)
Memory: 16 GB
System Firmware Version: 6723.61.3

Documentation requested for using botkit-cms as component Botkit App

Hi,

I tried to follow starting guide - adding botkit-cms as component in Botkit App. Unfortunately I can not make it works. Here are my steps:

  1. I install botkit and create by first botkit app
   npm install -g botkit
   botkit new --platform web
  1. I cd to the new botkit app folder and run following command
   npm install --save botkit-cms
  1. I modify bot.js , and add following lines:
   var controller = Botkit.socketbot(bot_options);
   var cms = require('botkit-cms')();
   cms.useLocalStudio(controller);
   cms.loadScriptsFromFile(__dirname + '/scripts.json'); // How I can get scripts.json ??

I believe I don't see any scripts.json , and I am not sure if my understanding to register new component is correct.
Would anyone help me and guide me what should I do to configure botkit-cms web?

Thanks.

Riwut

Vulnerabilities

I am using cpanel to host my bot, while installing (npm install) the bot-cmd I got 80 Vulnerabilities and I manage to fix 78 of them with npm audit fix, but those 2 remain. Are they crucial? How should I deal with them?

firefox_03_14-01-26

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.