如何启动从Bot到Skype for Business的出站邮件用户离线时

问题描述 投票:0回答:1

根据onetwo的说法,我发现可以向用户发送主动消息。但它似乎在用户离线时不起作用。可能吗?

我正在使用C#和bot框架V3。

我有两个问题:

  1. 即使用户不在线,也可以向用户发送消息
  2. 如果我使用下面的代码来自两个,是否可以启动对话框?如果有,怎么样?

我的代码如下

public class CustomWebAPIController : ApiController
{
    [HttpPost]

    [Route("api/CustomWebAPI")]
    public async Task<HttpResponseMessage> SendMessage([FromBody]string userobj)
    {
        try
        {

            //Initiate a Conversation
            string trustServiceUri = "https://api.skypeforbusiness.com/platformservice/botframework";
            MicrosoftAppCredentials.TrustServiceUrl(trustServiceUri);
            ConnectorClient connector = new ConnectorClient(new Uri(trustServiceUri));
            List<ChannelAccount> participants = new List<ChannelAccount>();
            participants.Add(new ChannelAccount("sip:[email protected]", "Agent"));
            ConversationParameters parameters = new ConversationParameters(true, new ChannelAccount("sip:[email protected]", "Bot"), participants, "TestTopic");
            ConversationResourceResponse response = connector.Conversations.CreateConversationAsync(parameters).Result;

            //Initiate another connector with the ServiceURL from above response.
            ConnectorClient connectorSend = new ConnectorClient(new Uri(response.ServiceUrl));
            IMessageActivity msg = Activity.CreateMessageActivity();
            msg.Recipient = new ChannelAccount("sip:[email protected]", "Agent");
            msg.Text = "text message";
            msg.Locale = "en-Us";
            msg.From = new ChannelAccount("sip:[email protected]", "Bot");
            msg.Type = ActivityTypes.Message;
            msg.Timestamp = DateTime.UtcNow;
            msg.ChannelId = "skypeforbusiness";
            msg.ServiceUrl = response.ServiceUrl;
            msg.Conversation = new ConversationAccount(isGroup: true, id: response.Id, name: null);
            //Send the message from Bot to User
            //var result = connectorSend.Conversations.SendToConversationAsync(msg.Conversation.Id, (Activity)msg).Result;
            await connector.Conversations.SendToConversationAsync((Activity)msg);

            var resp = new HttpResponseMessage(HttpStatusCode.OK);

            return resp;

        }
        catch (Exception ex)
        {
            return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
        }
    }
}
c# botframework skype-for-business
1个回答
0
投票

您引用的第一个文档指出:

只要用户与机器人进行用户发起的对话,并且仍然打开Skype对话窗口

这是Skype for Business Bots(预览版)的限制。

© www.soinside.com 2019 - 2024. All rights reserved.