How to send message later in bot framework?

前端 未结 2 1769
名媛妹妹
名媛妹妹 2020-12-21 20:57

I want my bot to be able to send some replies later. Like in alarm clock, when user says, ping me at 5 AM then I want to send message to the user at 5 AM. How can I send mes

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-21 21:37

    Without reply to an activity request, you can send a message to him like the following. I should mention that you must have the user's Id, and it means at least the user should have sent a message to the bot, to store his id.

    string userId ="123456789"; // For Example
    string serviceUrl = "https://telegram.botframework.com"; // For Example
    
    var connector = new ConnectorClient(new Uri(serviceUrl));
    IMessageActivity newMessage = Activity.CreateMessageActivity();
    newMessage.Type = ActivityTypes.Message;
    newMessage.From = new ChannelAccount("", "");
    newMessage.Conversation = new ConversationAccount(false, userId);
    newMessage.Recipient = new ChannelAccount(userId);
    newMessage.Text = "";
    await connector.Conversations.SendToConversationAsync((Activity)newMessage);
    

    The above code comes from here.

提交回复
热议问题