3
我正在處理一個bot項目。我如何實現這樣的功能?當我點擊卡片上的按鈕時,如何識別特定的附件?
在這裏,當我點擊機票的示範按鈕其提供航班相關信息,當我點擊顯示我的搜索按鈕,酒店提供了酒店的相關信息。
在我當前的工作機器人,當我點擊保留現在(如上圖顯示我的按鈕)我得到的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);
hi @ k48我在以上問題中添加了代碼,請通過他們的 – sateesh
因此,將Value =「立即預訂」更改爲您需要傳遞的實際值?例如。 ID。 – K48
實際上,在C#中,值是發送到聊天的內容。 –