Skip to content

Commit

Permalink
include sample bot
Browse files Browse the repository at this point in the history
  • Loading branch information
manuartero committed Jan 26, 2021
1 parent 6cfb713 commit 3d768a5
Show file tree
Hide file tree
Showing 7 changed files with 715 additions and 31 deletions.
31 changes: 24 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
const dotenv = require('dotenv')
const path = require('path')
const Logger = require('bunyan')

const { name, version } = require('./package.json')
const server = require('./src/server')
const { createBotAdapter } = require('./src/bot-adapter')
const { createBot } = require('./src/bot')
const { createServer } = require('./src/server')
const { createStorage } = require('./src/storage')

const appInfo = `${name}@${version}`
const log = new Logger({
name: appInfo
})

log.info('[STARTUP]', appInfo)

server.start({
appInfo,
/* load .env file before instanciating dependent objects (do NOT move) */
dotenv.config({ path: path.join(__dirname, '.env') })
log.info('[STARTUP] .env file read')

const adapter = createBotAdapter(log)
const storage = createStorage(log)
const bot = createBot(storage, log)

createServer({
log,
onMessage: () => {
log.info('TODO onMessage')
appInfo,
onMessage: async (req, res) => {
adapter.processActivity(req, res, async turnContext => {
// route to main dialog.
await bot.run(turnContext)
})
},
onNotify: () => {
onNotify: async input => {
log.info('TODO onNotify')
return {}
}
})
Loading

0 comments on commit 3d768a5

Please sign in to comment.