Created
August 15, 2018 18:45
-
-
Save amitbend/9c2109603f8913ab46470e3bea3be7c2 to your computer and use it in GitHub Desktop.
Proxy example for botframework botbuilder (node)
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
const request = require('request'); | |
server.get('/fw',(req,res)=>{ | |
let query = req.query | |
if (query['hub.verify_token'] === '<yourverifytoken>') { | |
return res.end(query['hub.challenge']) | |
} | |
return res.end('Error, wrong validation token') | |
}) | |
server.post('/fw',(req,res)=>{ | |
// redirection from here | |
let uri = 'https://facebook.botframework.com/api/v1/bots/<botname>'; | |
delete req.headers['X-LiveUpgrade'] | |
req.headers['Host'] = 'facebook.botframework.com' | |
request.post(uri,{headers : req.headers,body:JSON.stringify(req.body),rejectUnauthorized:false},(err,result)=>{ | |
if (err) console.log('error on fw:',err); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment