Last active
May 1, 2020 19:45
-
-
Save MichaelBarney/2165aa305af5734f4d023cb07977a2cf to your computer and use it in GitHub Desktop.
A simple implementation of a Botkit configuration for Facebook Messenger
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
// Import Botkit | |
const { Botkit } = require('botkit'); | |
// Import Facebook Adapter | |
const { FacebookAdapter, FacebookEventTypeMiddleware } = require('botbuilder-adapter-facebook'); | |
// Load process.env values from .env file | |
require('dotenv').config(); | |
// Configure Facebook Adapter | |
const adapter = new FacebookAdapter({ | |
enable_incomplete: true, | |
verify_token: process.env.FACEBOOK_VERIFY_TOKEN, | |
access_token: process.env.FACEBOOK_ACCESS_TOKEN, | |
app_secret: process.env.FACEBOOK_APP_SECRET, | |
}) | |
// emit events based on the type of facebook event being received | |
adapter.use(new FacebookEventTypeMiddleware()); | |
const controller = new Botkit({ | |
webhook_uri: '/api/messages', | |
adapter: adapter | |
}); | |
// Once the bot has booted up its internal services, you can use them to do stuff. | |
controller.ready(() => { | |
// load traditional developer-created local custom feature modules | |
controller.loadModules(__dirname + '/features'); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment