Created
July 20, 2018 14:26
-
-
Save ankitadhandha/8ddac4a284231ac8c8bce1b822cf7069 to your computer and use it in GitHub Desktop.
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"; | |
var express = require('express'); | |
var router = express.Router(); | |
var Slack = require('slack-node'); | |
var multer = require('multer'); | |
var multipart = multer(); | |
//sending messages to slack channel | |
router.post('/messages', multipart.fields([]), function(req, res) { | |
var webhookUri = "https://hooks.slack.com/services/T0000000/B00000000/I00000000000000000000"; | |
var slack = new Slack(); | |
slack.setWebhook(webhookUri); | |
slack.webhook({ | |
channel: "#contactus", | |
username: "Ankita", | |
text: "Contact Us message from Ontomatica:\nName: " + req.body.InputName + "\nEmail: "+ req.body.InputEmail +"\nInputPhone: "+ req.body.InputPhone + "\nMessage: "+ req.body.InputMessage +"\n" | |
}, function(err, response) { | |
}); | |
console.log(req.body.InputMessage + 'was sent to contactus channel' + 'url: ' + req.get('host')); | |
res.setHeader('AMP-Access-Control-Allow-Source-Origin', 'https://'+req.get('host')); | |
res.json({success:true}); | |
}); | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment