Примечание
Для доступа к этой странице требуется авторизация. Вы можете попробовать войти или изменить каталоги.
Для доступа к этой странице требуется авторизация. Вы можете попробовать изменить каталоги.
Messages are one of the most common types of activities to be used in agents as they're used to communicate to humans or other agents.
The MessageFactory
object provides methods that help developers create different types of message activities. Using the MessageFactory
makes it faster and easier to send responses. Using MessageFactory
is also less prone to errors in the construction of more complex types of messages.
Typically, the way a message is rendered in a UI depends on the client. Most clients accept a message of type text and adaptive cards (Clients vary in the supported version of adaptive cards).
Text
var textMessage = MessageFactory.Text("Hello, world!");
Adaptive cards
var adaptiveCardAttachment = new Attachment
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCardJson)
};
var adaptiveCardMessage = MessageFactory.Attachment(adaptiveCardAttachment);
await turnContext.SendActivityAsync(adaptiveCardMessage, cancellationToken);
Typing indicators
Typing indicators use a combination of a Text Message
and a Typing Activity
:
var typingMessage = MessageFactory.Text(string.Empty);
typingMessage.Type = ActivityTypes.Typing;
There are other types of supported messages in MessageFactory
, including Carousel
, List
, and SuggestedActions
.