Skip to content

Instantly share code, notes, and snippets.

@brunoluiz
Last active November 28, 2017 23:44
Show Gist options
  • Save brunoluiz/a76a0bef954e5f0be8e2314d3e977e4f to your computer and use it in GitHub Desktop.
Save brunoluiz/a76a0bef954e5f0be8e2314d3e977e4f to your computer and use it in GitHub Desktop.
medium-botframework-part1-echobot-app
NODE_ENV=development
PORT=80
APP_ID=
APP_SECRET=
const builder = require('botbuilder')
const dotenv = require('dotenv')
const express = require('express')
// Instantiate express
const app = express()
// Load .env configs
dotenv.config()
// Start Express listener
app.listen(process.env.PORT, () => console.log('Up and running!'))
// Instatiate the bot connector (will listen to messages)
const connector = new builder.ChatConnector({
appId: process.env.APP_ID,
appPassword: process.env.APP_SECRET
})
// Bind the messages endpoint to the bot connector listener
app.post('/api/messages', connector.listen())
// Instantiate the bot interface
const bot = new builder.UniversalBot(connector)
// Default/Fallback dialog
bot.dialog('/', (session) => {
// Get the user sent message
const message = session.message.text
// Echo back the message for the user
session.send(message)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment