Share via


ChoiceFactory class

A set of utility functions to assist with the formatting a 'message' activity containing a list of choices.

Properties

MAX_ACTION_TITLE_LENGTH

Methods

forChannel(string | TurnContext, (string | Choice)[], string, string, ChoiceFactoryOptions)

Returns a 'message' activity containing a list of choices that has been automatically formatted based on the capabilities of a given channel.

inline((string | Choice)[], string, string, ChoiceFactoryOptions)

Returns a 'message' activity containing a list of choices that has been formatted as an inline list.

list((string | Choice)[], string, string, ChoiceFactoryOptions)

Returns a 'message' activity containing a list of choices that has been formatted as an numbered or bulleted list.

toChoices(undefined | (string | Choice)[])

Takes a mixed list of string and Choice based choices and returns them as a Choice[].

Property Details

MAX_ACTION_TITLE_LENGTH

static MAX_ACTION_TITLE_LENGTH: 20 = 20

Property Value

20

Method Details

forChannel(string | TurnContext, (string | Choice)[], string, string, ChoiceFactoryOptions)

Returns a 'message' activity containing a list of choices that has been automatically formatted based on the capabilities of a given channel.

static function forChannel(channelOrContext: string | TurnContext, choices: (string | Choice)[], text?: string, speak?: string, options?: ChoiceFactoryOptions): Activity

Parameters

channelOrContext

string | TurnContext

Channel ID or context object for the current turn of conversation.

choices

(string | Choice)[]

List of choices to render.

text

string

(Optional) text of the message.

speak

string

(Optional) SSML to speak for the message.

options
ChoiceFactoryOptions

(Optional) formatting options to use when rendering as a list.

Returns

The created message activity.

inline((string | Choice)[], string, string, ChoiceFactoryOptions)

Returns a 'message' activity containing a list of choices that has been formatted as an inline list.

static function inline(choices: (string | Choice)[], text?: string, speak?: string, options?: ChoiceFactoryOptions): Activity

Parameters

choices

(string | Choice)[]

List of choices to render.

text

string

(Optional) text of the message.

speak

string

(Optional) SSML to speak for the message.

options
ChoiceFactoryOptions

(Optional) formatting options to tweak rendering of list.

Returns

The created message activity.

list((string | Choice)[], string, string, ChoiceFactoryOptions)

Returns a 'message' activity containing a list of choices that has been formatted as an numbered or bulleted list.

static function list(choices: (string | Choice)[], text?: string, speak?: string, options?: ChoiceFactoryOptions): Activity

Parameters

choices

(string | Choice)[]

List of choices to render.

text

string

(Optional) text of the message.

speak

string

(Optional) SSML to speak for the message.

options
ChoiceFactoryOptions

(Optional) formatting options to tweak rendering of list.

Returns

The created message activity.

toChoices(undefined | (string | Choice)[])

Takes a mixed list of string and Choice based choices and returns them as a Choice[].

static function toChoices(choices: undefined | (string | Choice)[]): Choice[]

Parameters

choices

undefined | (string | Choice)[]

List of choices to add.

Returns

Choice[]

A list of choices.