我正在研究一个机器人项目。我该如何实现这样的功能?
当我点击搜索航班的“显示我”按钮时,它会提供航班相关信息,当我点击搜索酒店的“显示我”按钮时,它会提供酒店相关信息。
在我现在的工作机器人中,我现在点击保留(如上图中的显示按钮)我收到的JSON响应中没有所选附件的信息,如下图所示。
那么,我怎么能在我的机器人中做同样的事情呢?
为此,我在我的项目
中写下以下代码行enter code here
place=activity.text(with in the place i am passing the city name)
MessagesController.hotelsList = await PropertyService.getHotelsList(place, DateTime.Now);
var hotellist = MessagesController.hotelsList;
Activity replyToConversation = message.CreateReply("Welcome to **Hotel Reservation Bot**." + "(Hi)");
replyToConversation.Recipient = message.From;
replyToConversation.Type = "message";
replyToConversation.Attachments = new List<Attachment>();
foreach (var list in hotellist.SearchResults)
{
List<CardAction> cardButtons = new List<CardAction>();
CardAction plButton = new CardAction()
{
Value ="Reserve Now",
Type = "imBack",
Title = "Reserve Now"
};
cardButtons.Add(plButton);
ThumbnailCard plCard = new ThumbnailCard()
{
Title = i + "." + "Name:" + list.Property.CallingDisplayName,
Subtitle = "Location:" + list.Property.Location.City,
Images = cardImages,
Buttons = cardButtons
};
Attachment plAttachment = plCard.ToAttachment();
replyToConversation.Attachments.Add(plAttachment);
i++;
}
replyToConversation.AttachmentLayout = AttachmentLayoutTypes.Carousel;
await context.PostAsync(replyToConversation);
答案 0 :(得分:0)
最好是显示您的代码,但一般的想法是按钮上的文字以及该按钮实际发送给聊天的内容必须不同:
var button = new CardAction() {
Title = "Show me",
Value = "Show restaurant #" + restaurantID,
Type = ActionTypes.imBack
};
当用户点击它时,他们会在聊天中看到"Show me"
,但实际上您的应用会在"Show restaurant #35"
中收到Activity.Text
。