3
我有一些代碼讓bot在啓動時發送消息(字符串)。在bot啓動時發送自適應卡作爲歡迎消息
但是,不要發送像您在下面的代碼中看到的文本。我試圖弄清楚在這種情況下你將如何發送一張自適應卡。我之前從RootDialog發送了一張卡片,但不是從MessageController.cs發送的。任何方向都會很棒!
else if (message.Type == ActivityTypes.ConversationUpdate)
{
// Handle conversation state changes, like members being added and removed
// Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
// Not available in all channels
IConversationUpdateActivity iConversationUpdated = message as IConversationUpdateActivity;
if (iConversationUpdated != null)
{
ConnectorClient connector = new ConnectorClient(new System.Uri(message.ServiceUrl));
foreach (var member in iConversationUpdated.MembersAdded ?? System.Array.Empty<ChannelAccount>())
{
// if the bot is added, then
if (member.Id == iConversationUpdated.Recipient.Id)
{
var reply = ((Activity)iConversationUpdated).CreateReply($"WELCOME MESSAGE HERE");
await connector.Conversations.ReplyToActivityAsync(reply);
}
}
}
}
感謝
在bot模擬器中測試了這個,效果很好,謝謝 –