Created
November 29, 2016 22:09
-
-
Save govi218/3eee681f1232e27d454d804d74ab5637 to your computer and use it in GitHub Desktop.
main file for implementing chatbot with heroku
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
'use strict' | |
const express = require('express') | |
const bodyParser = require('body-parser') | |
const request = require('request') | |
const app = express() | |
app.set('port', (process.env.PORT || 5000)) | |
// Process application/x-www-form-urlencoded | |
app.use(bodyParser.urlencoded({extended: false})) | |
// Process application/json | |
app.use(bodyParser.json()) | |
// Index route | |
app.get('/', function (req, res) { | |
res.send('Hello world, I am a chat bot') | |
}) | |
// for Facebook verification | |
app.get('/webhook/', function (req, res) { | |
if (req.query['hub.verify_token'] === 'my_voice_is_my_password_verify_me') { | |
res.send(req.query['hub.challenge']) | |
} | |
res.send('Error, wrong token') | |
}) | |
// Spin up the server | |
app.listen(app.get('port'), function() { | |
console.log('running on port', app.get('port')) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment