This repository has been archived by the owner on Mar 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Full example #6
Closed
Closed
Full example #6
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
module.exports = { | ||
|
||
/* | ||
Where the content is stored | ||
You can access this property from `bp.dataLocation` | ||
*/ | ||
dataDir: process.env.BOTPRESS_DATA_DIR || './data', | ||
|
||
/* | ||
The port on which the API and UI will be available | ||
*/ | ||
port: process.env.BOTPRESS_PORT || process.env.PORT || 3000, | ||
|
||
/* | ||
Some modules might generate static configuration files | ||
*/ | ||
modulesConfigDir: process.env.BOTPRESS_CONFIG_DIR || './modules_config', | ||
|
||
/* | ||
By default logs are enabled and available in `dataDir` | ||
*/ | ||
disableFileLogs: false, | ||
log: { | ||
file: 'bot.log', | ||
maxSize: 1e6 // 1mb | ||
}, | ||
|
||
/* | ||
Botpress collects some anonymous usage statistics to help us put our efforts at the right place | ||
*/ | ||
optOutStats: false, | ||
|
||
/* | ||
Where the notifications are stored. | ||
TODO: These should be stored in the database | ||
*/ | ||
notification: { | ||
file: 'notifications.json', | ||
maxLength: 50 | ||
}, | ||
|
||
/* | ||
Access control of admin panel | ||
*/ | ||
login: { | ||
enabled: process.env.NODE_ENV === 'production', | ||
tokenExpiry: '6 hours', | ||
password: process.env.BOTPRESS_PASSWORD || 'password', | ||
maxAttempts: 3, | ||
resetAfter: 10 * 60 * 1000 // 10 minutes | ||
}, | ||
|
||
/* | ||
Postgres configuration | ||
If Postgres is not enabled, Botpress uses SQLite 3 (file-based database) | ||
*/ | ||
postgres: { | ||
enabled: process.env.DATABASE === 'postgres', | ||
connection: process.env.DATABASE_URL, | ||
host: process.env.PG_HOST || '127.0.0.1', | ||
port: process.env.PG_PORT || 5432, | ||
user: process.env.PG_USER || '', | ||
password: process.env.PG_PASSWORD || '', | ||
database: process.env.PG_DB || '', | ||
ssl: process.env.PG_SSL || false | ||
}, | ||
|
||
umm: { | ||
/* | ||
The file containing the UMM Content (Universal Message Markdown) | ||
Can be an absolute or relative path (to your bot location) | ||
*/ | ||
contentPath: 'content.yml' | ||
}, | ||
|
||
middleware: { | ||
/* | ||
By default Botpress will automatically load all the middlewares before starting your bot | ||
If this is set to false, you should call `bp.middlewares.load` manually | ||
*/ | ||
autoLoading: true | ||
}, | ||
|
||
// **** Update this if you bought a Botpress license **** | ||
license: { | ||
// customerId: process.env.BOTPRESS_CUSTOMER_ID || 'your_customer_id_here', | ||
// licenseKey: process.env.BOTPRESS_LICENSE_KEY || 'your_key_here' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
welcome: # this is the #welcome bloc referenced in index.js | ||
- typing: true | ||
text: # Picks one randomly | ||
- Hey there! | ||
- Hello {{user.first_name}} | ||
- Good day :) | ||
- text: This is just a regular Hello World, I don't do anything ;) | ||
typing: 2s | ||
- text: Make sure to check out the 'index.js' file to see how I work | ||
typing: true | ||
- wait: 5s | ||
- text: You can say goodbye now | ||
typing: 1s | ||
|
||
goodbye: | ||
- text: You are leaving because of reason {{reason}} | ||
typing: true | ||
- Hope to see you back again soon! # if no other properties, you can just send a strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = function(bp) { | ||
bp.middlewares.load(); | ||
|
||
//Catch 'hello world' from 'facebook' | ||
bp.hear({ | ||
platform: 'slack', | ||
type: 'message', | ||
text: 'hello world' | ||
}, (event, next) => { | ||
console.log("HERE RECEUVED"); | ||
console.log(event.text); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "botpress", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": { | ||
"botpress": "1.x", | ||
"botpress-web": "1.x" | ||
}, | ||
"scripts": { | ||
"start": "botpress start", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "Botpress Proprietary License" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/* | ||
IMPORTANT! | ||
This file needs to be compiles to theme.css and be put at your bot's root | ||
*/ | ||
|
||
#app { | ||
/* LOGO */ | ||
.bp-sidebar-header { | ||
.bp-logo {} | ||
} | ||
|
||
|
||
/* SIDEBAR */ | ||
|
||
.bp-react-sidebar {} | ||
|
||
.bp-sidebar { | ||
.bp-sidebar-active {} | ||
} | ||
|
||
.bp-sidebar-footer { | ||
.bp-inner-footer {} | ||
.bp-name {} | ||
.bp-production {} | ||
.bp-edition-license {} | ||
.bp-buy {} | ||
|
||
.bp-status { | ||
.bp-dot { | ||
.bp-reached {} | ||
} | ||
} | ||
|
||
.bp-progress { | ||
.bp-used {} | ||
.bp-warning {} | ||
.bp-urgent {} | ||
.bp-reached {} | ||
} | ||
.bp-about {} | ||
} | ||
|
||
|
||
/* HEADER */ | ||
.bp-page-header {} | ||
.bp-navbar { | ||
.bp-slack {} | ||
} | ||
|
||
|
||
/* NOTIFICATIONS */ | ||
.bp-notifications-dropdown { | ||
.bp-hub-message {} | ||
.bp-top-menu { | ||
.bp-item {} | ||
.bp-level-success {} | ||
.bp-level-info {} | ||
.bp-level-error {} | ||
.bp-item-unread {} | ||
} | ||
} | ||
|
||
|
||
/* CONTENT */ | ||
.bp-content-wrapper {} | ||
|
||
|
||
/* MIDDLEWARE */ | ||
.bp-middleware-list { | ||
.bp-header { | ||
.bp-help {} | ||
} | ||
.bp-middleware { | ||
.bp-circle {} | ||
.bp-help-icon {} | ||
} | ||
|
||
.bp-disabled { | ||
.bp-circle {} | ||
} | ||
} | ||
|
||
|
||
/* MODULES */ | ||
.bp-module-panel { | ||
.bp-module-title {} | ||
.bp-module-description {} | ||
.bp-module-author {} | ||
.bp-module-license {} | ||
} | ||
|
||
|
||
/* LOGIN */ | ||
.bp-login { | ||
.bp-loading {} | ||
.bp-header {} | ||
} | ||
|
||
|
||
/* DASHBOARD */ | ||
.bp-dashboard { | ||
.bp-info { | ||
.bp-name {} | ||
.bp-description {} | ||
.bp-author {} | ||
.bp-version {} | ||
.bp-license {} | ||
.bp-where-from {} | ||
} | ||
|
||
.bp-hero { | ||
.bp-info {} | ||
|
||
.bp-contribution { | ||
.bp-rays-anim {} | ||
.bp-rays {} | ||
.bp-content { | ||
.bp-username {} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
/* ADMIN */ | ||
.bp-admin { | ||
.bp-user { | ||
.bp-table {} | ||
} | ||
.bp-token { | ||
.bp-table {} | ||
} | ||
} | ||
|
||
|
||
/* PROFILE */ | ||
.bp-profile {} | ||
|
||
|
||
/* ROLES */ | ||
.bp-roles {} | ||
|
||
|
||
/* GENERAL ELEMENTS */ | ||
.panel { | ||
.panel-heading {} | ||
} | ||
|
||
.form-control:focus {} | ||
.bp-button {} | ||
.bp-button-uninstall {} | ||
.bp-button-danger {} | ||
|
||
/* STYLES APPLY DIRECTLY TO APP */ | ||
|
||
height: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const path = require("path"); | ||
const express = require("express"); | ||
const Bot = require("@broid/kit"); | ||
const BroidSLack = require("@broid/slack"); | ||
const BroidKitBotpress = require("@broid/kit-botpress"); | ||
const bodyParser= require("body-parser"); | ||
|
||
const app = express(); | ||
const bot = new Bot({ logLevel: "info" }); | ||
const slack = new BroidSLack({ token: "<token>" }); | ||
|
||
bot.use(slack); | ||
bot.use(new BroidKitBotpress({ botpressPath: path.join(__dirname, 'botpress') })); | ||
|
||
app.use("/", bot.getRouter()); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
app.listen(8080); | ||
|
||
let sent = false; | ||
bot.hear('.*', 'Person') | ||
.subscribe((data) => { | ||
console.log("hear message", data.message); | ||
if (!sent) { | ||
sent = true; | ||
bot.sendText("Hi, How are you?", data.message); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "broid-kit-botpress-example", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"dependencies": { | ||
"@broid/kit": "^1.0.2", | ||
"@broid/kit-botpress": "^0.1.0", | ||
"@broid/messenger": "^2.0.4", | ||
"@broid/slack": "^2.1.1", | ||
"body-parser": "^1.17.2", | ||
"express": "^4.15.3" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhere here I want to see reply function call (or something like that), which will pass data back to broid-kit