Skip to content

Instantly share code, notes, and snippets.

@amitbend
Created August 15, 2018 18:45
Show Gist options
  • Save amitbend/9c2109603f8913ab46470e3bea3be7c2 to your computer and use it in GitHub Desktop.
Save amitbend/9c2109603f8913ab46470e3bea3be7c2 to your computer and use it in GitHub Desktop.
Proxy example for botframework botbuilder (node)
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