Forum Discussion
fallwhat
Jul 10, 2020Copper Contributor
Proactive Messages with MS Teams Conversation Bot Node js (BotFrameWork v4)
I'm trying to send proactive messages at MS Teams, I based myself on a MS Sample that you can find at this Link and deploy in Dev BotFrameWork , now I want to provide the proactive messages like a separate service, in a HTML Form page for example, were I ll request from user a mesage and a email of who you want to send a message, and a text of the message, I tried to provide this function bellow like an path of my API, and call this when I recive a request from HTML page, at this particular sample, I'll only send messages to a restrict group of users, I have the MS TeamsID, tenantID and all channel data of each user stored at an MYSql DB.
But I don't know how to connect this to my Message Endpoint on Dev.BotFramework.
Can anyone help me at this?
note: This code works when I provide the email and text to the bot inside a teams conversation, but I want to provide this like a external service
async SendPrivateMessageAsync(context, who, text) { var dados = {} var membros = [] const user = require('./sql').selectSingleUser who = who.replace(/\s*,\s*/g, ",") who = who.split(',') for (var n in who) { dados = (await user(this.poolConnection, who[n]) .then(resp => { return resp[0] }) .catch(err => { console.log(err) }) ) membros.shift() membros.push(dados) const message = MessageFactory.text(`Aviso: ${text}`); var ref = TurnContext.getConversationReference(context.activity); ref.user = membros[0]; await context.adapter.createConversation(ref, async (t1) => { const ref2 = TurnContext.getConversationReference(t1.activity); await t1.adapter.continueConversation(ref2, async (t2) => { await t2.sendActivity(message); }); }); await context.sendActivity(MessageFactory.text('All messages were sent')) } return true }
No RepliesBe the first to reply