CardAction class

Builder class to simplify adding actions to a card.

Constructors

CardAction(Session)

Creates a new CardAction.

Methods

call(Session, string, TextType)

Places a call to a phone number. The should include country code in +44/+1 format for Skype calls.

dialogAction(Session, string, string, TextType)

Binds a button or tap action to a named action registered for a dialog or globally off the bot. Can be used anywhere a postBack is valid. You may also statically bind a button to an action for something like Facebooks Persistent Menus. The payload for the button should be action?<action> for actions without data or action?<action>=<data> for actions with data.

displayText(TextType, any[])

(Optional) text to display in the chat feed if the button is clicked.

downloadFile(Session, string, TextType)

Downloads the specified file to the users device. Not currently supported for Skype.

image(string)

For buttons an image to include next to the buttons label. Not supported by all channels.

imBack(Session, string, TextType)

Sends a message to the bot for processing in a way that's visible to all members of the conversation. For some channels this may get mapped to a postBack.

invoke(Session, string, any, string)
messageBack(Session, string, TextType)

Sends a message to the bot for processing. A messageBack has the ability to act like both an imBack and a postBack.

openUrl(Session, string, TextType)

Opens the specified URL.

playAudio(Session, string, TextType)

Plays the specified audio file to the user. Not currently supported for Skype.

playVideo(Session, string, TextType)

Plays the specified video to the user. Not currently supported for Skype.

postBack(Session, string, TextType)

Sends a message to the bot for processing in a way that's hidden from all members of the conversation. For some channels this may get mapped to a imBack.

showImage(Session, string, TextType)

Opens the specified image in a native image viewer. For Skype only valid as a tap action on a CardImage.

text(TextType, any[])

(Optional) Text for this action.

title(TextType, any[])

Title of the action. For buttons this will be the label of the button. For tap actions this may be used for accesibility purposes or shown on hover.

toAction()

Returns the JSON for the action.

type(string)

Type of card action.

value(string)

The actions value.

Constructor Details

CardAction(Session)

Creates a new CardAction.

new CardAction(session?: Session)

Parameters

session
Session

(Optional) will be used to localize any text.

Method Details

call(Session, string, TextType)

Places a call to a phone number. The should include country code in +44/+1 format for Skype calls.

static function call(session: Session, number: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

number

string

title
TextType

Returns

dialogAction(Session, string, string, TextType)

Binds a button or tap action to a named action registered for a dialog or globally off the bot. Can be used anywhere a postBack is valid. You may also statically bind a button to an action for something like Facebooks Persistent Menus. The payload for the button should be action?<action> for actions without data or action?<action>=<data> for actions with data.

static function dialogAction(session: Session, action: string, data?: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

action

string

Name of the action to invoke when tapped.

data

string

(Optional) data to pass to the action when invoked. The IRecognizeActionResult.data property can be used to access this data. If using beginDialogAction() this value will be passed as part of the dialogs initial arguments.

title
TextType

(Optional) title to assign when binding the action to a button.

Returns

displayText(TextType, any[])

(Optional) text to display in the chat feed if the button is clicked.

function displayText(text: TextType, args: any[])

Parameters

text
TextType
args

any[]

Returns

downloadFile(Session, string, TextType)

Downloads the specified file to the users device. Not currently supported for Skype.

static function downloadFile(session: Session, url: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

url

string

title
TextType

Returns

image(string)

For buttons an image to include next to the buttons label. Not supported by all channels.

function image(url: string)

Parameters

url

string

Returns

imBack(Session, string, TextType)

Sends a message to the bot for processing in a way that's visible to all members of the conversation. For some channels this may get mapped to a postBack.

static function imBack(session: Session, msg: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

msg

string

title
TextType

Returns

invoke(Session, string, any, string)

static function invoke(session: Session, action: string, data: any, title: string)

Parameters

session
Session
action

string

data

any

title

string

Returns

messageBack(Session, string, TextType)

Sends a message to the bot for processing. A messageBack has the ability to act like both an imBack and a postBack.

static function messageBack(session: Session, msg: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

msg

string

title
TextType

Returns

openUrl(Session, string, TextType)

Opens the specified URL.

static function openUrl(session: Session, url: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

url

string

title
TextType

Returns

playAudio(Session, string, TextType)

Plays the specified audio file to the user. Not currently supported for Skype.

static function playAudio(session: Session, url: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

url

string

title
TextType

Returns

playVideo(Session, string, TextType)

Plays the specified video to the user. Not currently supported for Skype.

static function playVideo(session: Session, url: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

url

string

title
TextType

Returns

postBack(Session, string, TextType)

Sends a message to the bot for processing in a way that's hidden from all members of the conversation. For some channels this may get mapped to a imBack.

static function postBack(session: Session, msg: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

msg

string

title
TextType

Returns

showImage(Session, string, TextType)

Opens the specified image in a native image viewer. For Skype only valid as a tap action on a CardImage.

static function showImage(session: Session, url: string, title?: TextType)

Parameters

session
Session

(Optional) Current session object for the conversation. If specified will be used to localize titles.

url

string

title
TextType

Returns

text(TextType, any[])

(Optional) Text for this action.

function text(text: TextType, args: any[])

Parameters

text
TextType
args

any[]

Returns

title(TextType, any[])

Title of the action. For buttons this will be the label of the button. For tap actions this may be used for accesibility purposes or shown on hover.

function title(text: TextType, args: any[])

Parameters

text
TextType
args

any[]

Returns

toAction()

Returns the JSON for the action.

function toAction()

Returns

type(string)

Type of card action.

function type(t: string)

Parameters

t

string

Returns

value(string)

The actions value.

function value(v: string)

Parameters

v

string

Returns