MessageFactory Class
- java.
lang. Object - com.
microsoft. bot. builder. MessageFactory
- com.
public final class MessageFactory
Contains utility methods for various message types a bot can return.
Create and send a message. Activity message = MessageFactory.text("Hello World"); conext.sendActivity(message);
The following apply to message actions in general. See the channel's documentation for limits imposed upon the contents of the text of the message to send.
To control various characteristics of your bot's speech such as voice, rate, volume, pronunciation, and pitch, specify test to speak in Speech Synthesis Markup Language (SSML) format.
Channels decide how each card action manifests in their user experience. In most cases, the cards are clickable. In others, they may be selected by speech input. In cases where the channel does not offer an interactive activation experience (e.g., when interacting over SMS), the channel may not support activation whatsoever. The decision about how to render actions is controlled by normative requirements elsewhere in this document (e.g. within the card format, or within the suggested actions definition).
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| static Activity |
attachment(Attachment attachment)
Returns a message activity that contains an attachment. |
| static Activity |
attachment(Attachment attachment, String text)
Returns a message activity that contains an attachment. |
| static Activity |
attachment(Attachment attachment, String text, String ssml, InputHints inputHint)
Returns a message activity that contains an attachment. |
| static Activity |
attachment(List<Attachment> attachments)
Returns a message activity that contains an attachment. |
| static Activity |
attachment(List<Attachment> attachments, String text, String ssml, InputHints inputHint)
Returns a message activity that contains an attachment. |
| static Activity |
carousel(List<Attachment> attachments, String text)
Returns a message activity that contains a collection of attachments, in a list. |
| static Activity |
carousel(List<Attachment> attachments, String text, String ssml, InputHints inputHint)
Returns a message activity that contains a collection of attachments, in a list. |
| static Activity |
contentUrl(String url, String contentType)
Returns a message activity that contains a single image or video. |
| static Activity |
contentUrl(String url, String contentType, String name, String text, String ssml, InputHints inputHint)
Returns a message activity that contains a single image or video. |
| static Activity |
suggestedActions(List<String> actions, String text)
Returns a message that includes a set of suggested actions and optional text. |
| static Activity |
suggestedActions(List<String> actions, String text, String ssml, InputHints inputHint)
Returns a message that includes a set of suggested actions and optional text. |
| static Activity |
suggestedCardActions(List<CardAction> actions, String text)
Returns a message that includes a set of suggested actions and optional text. |
| static Activity |
suggestedCardActions(List<CardAction> actions, String text, String ssml, InputHints inputHint)
Returns a message that includes a set of suggested actions and optional text. |
| static Activity |
text(String text)
Returns a simple text message. |
| static Activity |
text(String text, String ssml, InputHints inputHint)
Returns a simple text message. |
Methods inherited from java.lang.Object
Method Details
attachment
public static Activity attachment(Attachment attachment)
Returns a message activity that contains an attachment.
Parameters:
Returns:
attachment
public static Activity attachment(Attachment attachment, String text)
Returns a message activity that contains an attachment.
Parameters:
Returns:
attachment
public static Activity attachment(Attachment attachment, String text, String ssml, InputHints inputHint)
Returns a message activity that contains an attachment.
Parameters:
Returns:
attachment
public static Activity attachment(List
Returns a message activity that contains an attachment.
Parameters:
Returns:
attachment
public static Activity attachment(List
Returns a message activity that contains an attachment.
Parameters:
Returns:
carousel
public static Activity carousel(List
Returns a message activity that contains a collection of attachments, in a list.
Parameters:
Returns:
carousel
public static Activity carousel(List
Returns a message activity that contains a collection of attachments, in a list.
Parameters:
Returns:
contentUrl
public static Activity contentUrl(String url, String contentType)
Returns a message activity that contains a single image or video.
Parameters:
Returns:
contentUrl
public static Activity contentUrl(String url, String contentType, String name, String text, String ssml, InputHints inputHint)
Returns a message activity that contains a single image or video.
Parameters:
Returns:
suggestedActions
public static Activity suggestedActions(List
Returns a message that includes a set of suggested actions and optional text. // Create the activity and add suggested actions. Activity activity = MessageFactory.suggestedActions( new String[] { "red", "green", "blue" }, "Choose a color");
// Send the activity as a reply to the user. context.sendActivity(activity);
Parameters:
Returns:
suggestedActions
public static Activity suggestedActions(List
Returns a message that includes a set of suggested actions and optional text. // Create the activity and add suggested actions. Activity activity = MessageFactory.suggestedActions( new String[] { "red", "green", "blue" }, "Choose a color");
// Send the activity as a reply to the user. context.sendActivity(activity);
Parameters:
Returns:
suggestedCardActions
public static Activity suggestedCardActions(List
Returns a message that includes a set of suggested actions and optional text.
Parameters:
Returns:
suggestedCardActions
public static Activity suggestedCardActions(List
Returns a message that includes a set of suggested actions and optional text.
Parameters:
Returns:
text
public static Activity text(String text)
Returns a simple text message.
Parameters:
Returns:
text
public static Activity text(String text, String ssml, InputHints inputHint)
Returns a simple text message.
Parameters:
Returns: