ChoiceFactory Class

  • java.lang.Object
    • com.microsoft.bot.dialogs.choices.ChoiceFactory

public final class ChoiceFactory

Assists with formatting a message activity that contains a list of choices.

Method Summary

Modifier and Type Method and Description
static Activity forChannel(String channelId, List<Choice> list, String text)

Creates an Activity that includes a list of choices formatted based on the capabilities of a given channel.

static Activity forChannel(String channelId, List<Choice> list, String text, String speak, ChoiceFactoryOptions options)

Creates an Activity that includes a list of choices formatted based on the capabilities of a given channel.

static Activity heroCard(List<Choice> choices)

Creates an Activity with a HeroCard based on a list of Choices.

static Activity heroCard(List<Choice> choices, String text)

Creates an Activity with a HeroCard based on a list of Choices.

static Activity heroCard(List<Choice> choices, String text, String speak)

Creates an Activity with a HeroCard based on a list of Choices.

static Activity inline(List<Choice> choices, String text)

Creates an Activity that includes a list of choices formatted as an inline list.

static Activity inline(List<Choice> choices, String text, String speak, ChoiceFactoryOptions options)

Creates an Activity that includes a list of choices formatted as an inline list.

static Activity list(List<Choice> choices)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

static Activity list(List<Choice> choices, String text)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

static Activity list(List<Choice> choices, String text, String speak, ChoiceFactoryOptions options)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

static Activity listFromStrings(List<String> choices)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

static Activity listFromStrings(List<String> choices, String text, String speak, ChoiceFactoryOptions options)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

static Activity suggestedAction(List<Choice> choices)

Creates an Activity that includes a list of card actions.

static Activity suggestedAction(List<Choice> choices, String text)

Creates an Activity that includes a list of card actions.

static Activity suggestedAction(List<Choice> choices, String text, String speak)

Creates an Activity that includes a list of card actions.

static Activity suggestedActionFromStrings(List<String> choices)

Creates an Activity that includes a list of card actions.

static Activity suggestedActionFromStrings(List<String> choices, String text, String speak)

Creates an Activity that includes a list of card actions.

static java.util.List<Choice> toChoices(String[] choices)

Returns a list of strings as a list of Choices.

static java.util.List<Choice> toChoices(List<String> choices)

Returns a list of strings as a list of Choices.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Method Details

forChannel

public static Activity forChannel(String channelId, List list, String text)

Creates an Activity that includes a list of choices formatted based on the capabilities of a given channel.

Parameters:

channelId - A channel ID. The Connector.Channels class contains known channel IDs.
list - The list of choices to include.
text - The text of the message to send. Can be null.

Returns:

The created Activity

forChannel

public static Activity forChannel(String channelId, List list, String text, String speak, ChoiceFactoryOptions options)

Creates an Activity that includes a list of choices formatted based on the capabilities of a given channel.

Parameters:

channelId - A channel ID. The Connector.Channels class contains known channel IDs.
list - The list of choices to include.
text - The text of the message to send. Can be null.
speak - The text to be spoken by your bot on a speech-enabled channel. Can be null.
options - The formatting options to use when rendering as a list. If null, the default options are used.

Returns:

The created Activity

heroCard

public static Activity heroCard(List choices)

Creates an Activity with a HeroCard based on a list of Choices.

Parameters:

choices - The list of choices to include.

Returns:

The created Activity.

heroCard

public static Activity heroCard(List choices, String text)

Creates an Activity with a HeroCard based on a list of Choices.

Parameters:

choices - The list of choices to include.
text - The text of the message to send.

Returns:

The created Activity.

heroCard

public static Activity heroCard(List choices, String text, String speak)

Creates an Activity with a HeroCard based on a list of Choices.

Parameters:

choices - The list of choices to include.
text - The text of the message to send.
speak - The text to be spoken by your bot on a speech-enabled channel.

Returns:

The created Activity.

inline

public static Activity inline(List choices, String text)

Creates an Activity that includes a list of choices formatted as an inline list.

Parameters:

choices - The list of choices to include.
text - The text of the message to send. Can be null.

Returns:

The created Activity.

inline

public static Activity inline(List choices, String text, String speak, ChoiceFactoryOptions options)

Creates an Activity that includes a list of choices formatted as an inline list.

Parameters:

choices - The list of choices to include.
text - The text of the message to send. Can be null.
speak - The text to be spoken by your bot on a speech-enabled channel. Cab be null.
options - The formatting options to use when rendering as a list. Can be null.

Returns:

The created Activity.

list

public static Activity list(List choices)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

Parameters:

choices - The list of choices to include.

Returns:

The created Activity.

list

public static Activity list(List choices, String text)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

Parameters:

choices - The list of choices to include.
text - The text of the message to send.

Returns:

The created Activity.

list

public static Activity list(List choices, String text, String speak, ChoiceFactoryOptions options)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

Parameters:

choices - The list of choices to include.
text - The text of the message to send.
speak - The text to be spoken by your bot on a speech-enabled channel.
options - The formatting options to use when rendering as a list.

Returns:

The created Activity.

listFromStrings

public static Activity listFromStrings(List choices)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

Parameters:

choices - The list of strings to include as Choices.

Returns:

The created Activity.

listFromStrings

public static Activity listFromStrings(List choices, String text, String speak, ChoiceFactoryOptions options)

Creates a message activity that includes a list of choices formatted as a numbered or bulleted list.

Parameters:

choices - The list of strings to include as Choices.
text - The text of the message to send.
speak - The text to be spoken by your bot on a speech-enabled channel.
options - The formatting options to use when rendering as a list.

Returns:

The created Activity.

suggestedAction

public static Activity suggestedAction(List choices)

Creates an Activity that includes a list of card actions.

Parameters:

choices - The list of choices to include.

Returns:

The created Activity.

suggestedAction

public static Activity suggestedAction(List choices, String text)

Creates an Activity that includes a list of card actions.

Parameters:

choices - The list of choices to include.
text - The text of the message to send.

Returns:

The created Activity.

suggestedAction

public static Activity suggestedAction(List choices, String text, String speak)

Creates an Activity that includes a list of card actions.

Parameters:

choices - The list of choices to include.
text - The text of the message to send.
speak - The text to be spoken by your bot on a speech-enabled channel.

Returns:

The created Activity.

suggestedActionFromStrings

public static Activity suggestedActionFromStrings(List choices)

Creates an Activity that includes a list of card actions.

Parameters:

choices - The list of strings to include as actions.

Returns:

The created Activity.

suggestedActionFromStrings

public static Activity suggestedActionFromStrings(List choices, String text, String speak)

Creates an Activity that includes a list of card actions.

Parameters:

choices - The list of strings to include as actions.
text - The text of the message to send.
speak - The text to be spoken by your bot on a speech-enabled channel.

Returns:

The created Activity.

toChoices

public static List toChoices(String[] choices)

Returns a list of strings as a list of Choices.

Parameters:

choices - The strings to convert.

Returns:

A List of Choices.

toChoices

public static List toChoices(List choices)

Returns a list of strings as a list of Choices.

Parameters:

choices - The list of strings to convert.

Returns:

A List of Choices.

Applies to