如何检查MSTEAMS上的成员状态

时间:2018-06-06 08:55:05

标签: node.js botframework microsoft-teams

为了检查MSTeams上的会员状态(在线或离线),我想通过电子邮件获取会员身份。

我已接近Bot Builder Microsoft Teams Extensions并撰写示例代码以了解我的想法:

var teams = require("botbuilder-teams");

bot.dialog('FetchMemberInfo', function (session) {
    var memberEmail = 'billzeng@csc.com';

    var connector = new teams.TeamsChatConnector({
        appId: process.env.MICROSOFT_APP_ID,
        appPassword: process.env.MICROSOFT_APP_PASSWORD
    });

    connector.fetchMemberInfo(session.message.address.serviceUrl, memberEmail, function (err, result) {
        if (err) {
            session.endDialog('There is some error');
        }
        else {
            var memberStatus = result.member.status;
            session.endDialog('%s', JSON.stringify(result));
        }
    });
});

我只有会员的电子邮件,想要获得会员身份。那么,我的示例代码中需要更新哪些位置以获取包含成员状态的成员信息?如果有的话,我也欢迎任何其他建议。

2 个答案:

答案 0 :(得分:4)

获取/设置用户状态的API尚不可用。这是在API路线图上,但从今天开始是不可能的

答案 1 :(得分:0)

实际上,我们可以通过Skype4Business API获取用户状态(在线/离线)。这是示例代码:

   var authContext = {
        id: botSetting.identifier,
        username: botSetting.username,
        password: botSetting.password,
        domain: botSetting.domain,
        _links: {},
        /*1 seconds*/
        messageInterval: 1000 * botSetting.messageInterval,
        /*30 seconds*/
        messageTimeout: 1000 * botSetting.messageTimeout,
        /*3 minutes, unit in second*/
        statusUpdateInterval: 1000 * botSetting.statusUpdateInterval,
        AppId: null,
        AppPath: null,
        EndPointId: botSetting.endpointId,
        Culture: botSetting.culture,
        UserAgent: botSetting.userAgent,
        /* default timeout to wait for user to accept message is 5 minutes */
        acceptMessageInvitationTimeout: botSetting.acceptMessageInvitationTimeout * 1000,
        logUnhandleEvent: botSetting.logUnhandleEvent,
        RootAppUrl: null,
        /*default is 30 seconds, unit in second*/
        statusAwarenessInterval: (CONFIG.PROACTIVE_MESSAGE_INTERVAL_IN_SECONDS || 30) * SECOND_TO_MILLISECONDS, //30 seconds
        remindProcessProactiveMsgInterval: 1000 * 60 * CONFIG.PROACTIVE_MESSAGE_REMIND_IN_MINUTES,
        proactive_interval: process.env.PROACTIVE_UPDATE_INTERVAL_IN_MINUTES || 2
    };


function getUserAvailibility(receiver){
        var url = authContext._embedded.people._links.self.href;
        var requestResourceUrl = stringFormat("{0}{1}/{2}/presence",authContext.BaseUri, url, receiver);
        console.log("SkypeForBusinessBot getUserAvailibility " + receiver + " with url: " + requestResourceUrl);
         return $q.nfcall(request.get, requestResourceUrl,
                            { headers: authContext.headers, json: true });

    }

注意:收件人是用户的电子邮件