diff --git a/node/simpleSendMessage/index.js b/node/simpleSendMessage/index.js index 502c201..b7d5a96 100644 --- a/node/simpleSendMessage/index.js +++ b/node/simpleSendMessage/index.js @@ -16,9 +16,9 @@ var connector = new builder.ChatConnector({ var bot = new builder.UniversalBot(connector); -function sendProactiveMessage(addr) { +function sendProactiveMessage(addr, customMessage) { var msg = new builder.Message().address(addr); - msg.text('Hello, this is a notification'); + msg.text(customMessage || 'Hello, this is a notification'); msg.textLocale('en-US'); bot.send(msg); } @@ -31,6 +31,15 @@ server.get('/api/CustomWebApi', (req, res, next) => { next(); } ); +// Receive a custom message via POST body. +// For example, call this api with following JSON: {"message":"Hello World"} +server.post('/api/CustomWebApi', (req, res, next) => { + const message = req.params.message; + sendProactiveMessage(savedAddress, message); + res.send('triggered'); + next(); + } +); bot.dialog('/', function(session, args) {