I am using bot framework to have a chat bot. I use it in Microsoft Teams.
I want to send a message from user to bot programetically. But i am not able to do that.
I tried using direct line but it didnt help me. I am new to this bot framework.
var directLineSecret = "directlinesecretkey";
var client = new DirectLineClient(directLineSecret);
var conversation = await client.Conversations.StartConversationAsync();
var testActivity = new Activity
{
From = new Microsoft.Bot.Connector.DirectLine.ChannelAccount(objectid, userName),
Type = Microsoft.Bot.Connector.DirectLine.ActivityTypes.Message,
Text = "Hello from the PCE!"
};
var response = await client.Conversations.PostActivityAsync(conversation.ConversationId, testActivity);
Activity userMessage = new Activity
{
From = new Microsoft.Bot.Connector.DirectLine.ChannelAccount(objectid, userName),
Text = "test",
Type = Microsoft.Bot.Schema.ActivityTypes.Message
};
await client.Conversations.PostActivityAsync(conversation.ConversationId, testActivity);
await client.Conversations.PostActivityAsync(conversation.ConversationId, userMessage);
Please help me with this. While executing this code i am getting response in var response but the message is not sent nor i see the log in the bot framework.
An Adaptive Card can simulate an imBack
with an adaptive submit action under two conditions:
Data
property must be a string (the text to be sent from the user) Here's a example of how you might create and send such a card in BotBuilder v4 using the AdaptiveCards NuGet package:
var card = new AdaptiveCard
{
Body = { new AdaptiveTextBlock("Adaptive Card") },
Actions = { new AdaptiveSubmitAction { Title = "Say 'test'", Data = "test" } },
};
var reply = (Activity)MessageFactory.Attachment(new Attachment {
ContentType = AdaptiveCard.ContentType,
Content = card,
});
await turnContext.SendActivityAsync(reply);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.