Reputation: 1328
i am using nodejs v4 version of the botbuilder https://learn.microsoft.com/en-us/javascript/api/botbuilder/?view=botbuilder-ts-latest
My current code is picked from echo bot and looks like below
const { ActivityHandler } = require('botbuilder');
class ScanBuddyMsBot extends ActivityHandler {
constructor() {
super();
this.onMessage(async (context:any, next:any) => {
await context.sendActivity(`You said '${ context.activity.text }'`);
// By calling next() you ensure that the next BotHandler is run.
await next();
});
}
}
module.exports.ScanBuddyMsBot = ScanBuddyMsBot;
I am looking a way to fetch user email sending message to my bot. I can see in the context activity, conversation id and service url but not the email id.
in another variation of this i am using below way to get email id and not sure how to make below code work for above
var bot = new builder.UniversalBot(connector, async function(session) {
var teamId = session.message.address.conversation.id;
connector.fetchMembers(
session.message.address.serviceUrl,
teamId,
async (err, result) => {
if (err) {
session.send('We faced an error trying to process this information', err);
return
}
else {
const email = result[0].email
}
Upvotes: 1
Views: 509
Reputation: 12264
In Bot Builder v4, you can access that REST API using the getConversationMembers
function:
/**
*
* @param {TurnContext} turnContext
*/
async testTeams(turnContext) {
const activity = turnContext.activity;
const connector = turnContext.adapter.createConnectorClient(activity.serviceUrl);
const response = await connector.conversations.getConversationMembers(activity.conversation.id);
const email = response[0].email;
await turnContext.sendActivity(email);
}
Please refer to the documentation and the samples to better understand how to use the v4 SDK.
Upvotes: 1