簡體   English   中英

用戶離線時如何啟動從Bot到Skype for Business的出站郵件

[英]How to Initiate Outbound Messages from Bot to Skype for Business When users are offline

根據一個兩個 ,我發現可以向用戶發送主動消息。 但是,當用戶離線時,它似乎不起作用。 可能嗎?

我正在使用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:XXXXX@XXXXX.onmicrosoft.com", "Agent"));
            ConversationParameters parameters = new ConversationParameters(true, new ChannelAccount("sip:XXXXXbot@XXXXX.onmicrosoft.com", "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:XXXXX@XXXXX.onmicrosoft.com", "Agent");
            msg.Text = "text message";
            msg.Locale = "en-Us";
            msg.From = new ChannelAccount("sip:XXXXXbot@XXXXX.onmicrosoft.com", "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);
        }
    }
}

您引用的第一個文檔指出:

只要用戶處於與機器人的用戶發起的對話中,並且仍打開Skype對話窗口

當前,這是Skype for Business Bots的限制(預覽)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM