Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Add example receiving custom message via POST body #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions node/simpleSendMessage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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) {

Expand Down