我想通过Web聊天平台向我的MS机器人添加一条欢迎消息,这条消息将在Iframe打开后立即显示。 我怎么能这样做?
像这样的东西:谢谢!
编辑:我找到了this解决方案,但我找不到活动处理程序所在的位置..
感谢您的帮助..
答案 0 :(得分:0)
在MessagesController.cs中,您将找到处理Activity类型的代码。这是我们建议发送欢迎信息的方式:
else if (message.Type == ActivityTypes.ConversationUpdate)
{
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(
$"Hi! I'm Botty McBotface. I generally can do stuff, but can also do things.");
await connector.Conversations.ReplyToActivityAsync(reply);
}
}
}
}