【问题标题】:Sending Direct Message to a user向用户发送直接消息
【发布时间】:2017-05-16 20:11:11
【问题描述】:

现在,我的机器人在 slack 中收听一个名为“teams”的频道,并在该频道中回复。我希望它改为通过直接消息回复用户(比如“User1”)。我该如何构造一个消息来做到这一点?

谢谢!

【问题讨论】:

    标签: node.js bots botframework slack


    【解决方案1】:

    您可以按如下方式发送私信:

        var response = await activityContext.ConnectorAPI.Conversations.CreateDirectConversationAsync(activity.Recipient, activity.From);
    
        var reply = activity.CreateReply($"This is a direct message to {activity.From.Name ?? activity.From.Id} : {activity.Text}");
        reply.Conversation = new ConversationAccount(id: response.Id);
        reply.ReplyToId = null;
    
        await activityContext.ConnectorAPI.Conversations.SendToConversationAsync(reply);
    

    【讨论】:

    • 这是 C# 吗?你知道在 Node.js 中实现它的方法吗?谢谢。
    猜你喜欢
    • 2018-12-16
    • 2017-10-12
    • 1970-01-01
    • 2021-04-07
    • 2015-02-25
    • 1970-01-01
    • 2017-08-13
    • 2021-05-15
    • 2021-01-07
    相关资源
    最近更新 更多