Skip to content

Instantly share code, notes, and snippets.

@codefoster
Created March 15, 2018 19:00
Show Gist options
  • Save codefoster/90fab31316023714b1cdce974c8c431e to your computer and use it in GitHub Desktop.
Save codefoster/90fab31316023714b1cdce974c8c431e to your computer and use it in GitHub Desktop.
Bot Framework v4 m2 Echo Bot with BotFrameworkAdapter
import { BotFrameworkAdapter } from 'botbuilder';
import * as restify from 'restify';
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log(`${server.name} listening to ${server.url}`);
});
const adapter = new BotFrameworkAdapter();
server.post('/api/messages', (req, res) => {
adapter.processRequest(req, res, async ctx => {
if (ctx.request.type === 'message') {
ctx.sendActivity(ctx.request.text);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment