MessageFactory クラス

ボットが返すことができるさまざまなメッセージの種類の書式設定を支援するように設計されたユーティリティ関数のセット。

コンストラクター

MessageFactory()

メソッド

attachment

添付ファイルを含む 1 つのメッセージ アクティビティを返します。

message = MessageFactory.attachment(CardFactory.hero_card(HeroCard(title='White T-Shirt', images=[CardImage(url= 'https://example.com/whiteShirt.jpg' )],

buttons=[CardAction(title='buy')]))

await context.send_activity(message)

carousel

カルーセル レイアウトを使用して添付ファイルのセットを表示するメッセージを返します。

message = MessageFactory.carousel([CardFactory.hero_card(HeroCard(title='title1', images=[CardImage(url='imageUrl1')], buttons=[CardAction(title='button1')]))

CardFactory.hero_card(HeroCard(title='title2', images=[CardImage(url='imageUrl2')], buttons=[CardAction(title='button2')])),

CardFactory.hero_card(HeroCard(title='title3', images=[CardImage(url='imageUrl3')], buttons=[CardAction(title='button3')])])

await context.send_activity(message)

content_url

1 つの画像またはビデオをユーザーに表示するメッセージを返します。

message = MessageFactory.content_url('https://example.com/hawaii.jpg', 'image/jpeg', 'Hawaii Trip', 'A photo from our family vacation.')

await context.send_activity(message)

list

リスト フォームに添付ファイルのセットを表示するメッセージを返します。

message = MessageFactory.list([CardFactory.hero_card(HeroCard(title='title1', images=[CardImage(url='imageUrl1')], buttons=[CardAction(title='button1')]))

CardFactory.hero_card(HeroCard(title='title2', images=[CardImage(url='imageUrl2')], buttons=[CardAction(title='button2')])),

CardFactory.hero_card(HeroCard(title='title3', images=[CardImage(url='imageUrl3')], buttons=[CardAction(title='button3')])])

await context.send_activity(message)

suggested_actions

一連の推奨されるアクションと省略可能なテキストを含むメッセージを返します。

message = MessageFactory.suggested_actions([CardAction(title='a', type=ActionTypes.im_back, value='a'), CardAction(title='b', type=ActionTypes.im_back, value='b'), CardAction(title='c', type=ActionTypes.im_back, value='c')], 'Choose a color')

await context.send_activity(message)

text

単純なテキスト メッセージを返します。

message = MessageFactory.text('Greetings from example message') await context.send_activity(message)

attachment

添付ファイルを含む 1 つのメッセージ アクティビティを返します。

message = MessageFactory.attachment(CardFactory.hero_card(HeroCard(title='White T-Shirt', images=[CardImage(url= 'https://example.com/whiteShirt.jpg' )],

buttons=[CardAction(title='buy')]))

await context.send_activity(message)

static attachment(attachment: Attachment, text: str = None, speak: str = None, input_hint: InputHints | str = None)

パラメーター

名前 説明
attachment
必須
text
規定値: None
speak
規定値: None
input_hint
規定値: None

カルーセル レイアウトを使用して添付ファイルのセットを表示するメッセージを返します。

message = MessageFactory.carousel([CardFactory.hero_card(HeroCard(title='title1', images=[CardImage(url='imageUrl1')], buttons=[CardAction(title='button1')]))

CardFactory.hero_card(HeroCard(title='title2', images=[CardImage(url='imageUrl2')], buttons=[CardAction(title='button2')])),

CardFactory.hero_card(HeroCard(title='title3', images=[CardImage(url='imageUrl3')], buttons=[CardAction(title='button3')])])

await context.send_activity(message)

static carousel(attachments: List[Attachment], text: str = None, speak: str = None, input_hint: InputHints | str = None) -> Activity

パラメーター

名前 説明
attachments
必須
text
規定値: None
speak
規定値: None
input_hint
規定値: None

content_url

1 つの画像またはビデオをユーザーに表示するメッセージを返します。

message = MessageFactory.content_url('https://example.com/hawaii.jpg', 'image/jpeg', 'Hawaii Trip', 'A photo from our family vacation.')

await context.send_activity(message)

static content_url(url: str, content_type: str, name: str = None, text: str = None, speak: str = None, input_hint: InputHints | str = None)

パラメーター

名前 説明
url
必須
content_type
必須
name
規定値: None
text
規定値: None
speak
規定値: None
input_hint
規定値: None

list

リスト フォームに添付ファイルのセットを表示するメッセージを返します。

message = MessageFactory.list([CardFactory.hero_card(HeroCard(title='title1', images=[CardImage(url='imageUrl1')], buttons=[CardAction(title='button1')]))

CardFactory.hero_card(HeroCard(title='title2', images=[CardImage(url='imageUrl2')], buttons=[CardAction(title='button2')])),

CardFactory.hero_card(HeroCard(title='title3', images=[CardImage(url='imageUrl3')], buttons=[CardAction(title='button3')])])

await context.send_activity(message)

static list(attachments: List[Attachment], text: str = None, speak: str = None, input_hint: InputHints | str = None) -> Activity

パラメーター

名前 説明
attachments
必須
text
規定値: None
speak
規定値: None
input_hint
規定値: None

suggested_actions

一連の推奨されるアクションと省略可能なテキストを含むメッセージを返します。

message = MessageFactory.suggested_actions([CardAction(title='a', type=ActionTypes.im_back, value='a'), CardAction(title='b', type=ActionTypes.im_back, value='b'), CardAction(title='c', type=ActionTypes.im_back, value='c')], 'Choose a color')

await context.send_activity(message)

static suggested_actions(actions: List[CardAction], text: str = None, speak: str = None, input_hint: InputHints | str = InputHints.accepting_input) -> Activity

パラメーター

名前 説明
actions
必須
text
規定値: None
speak
規定値: None
input_hint
規定値: InputHints.accepting_input

text

単純なテキスト メッセージを返します。

message = MessageFactory.text('Greetings from example message') await context.send_activity(message)

static text(text: str, speak: str = None, input_hint: InputHints | str = InputHints.accepting_input) -> Activity

パラメーター

名前 説明
text
必須
speak
規定値: None
input_hint
規定値: InputHints.accepting_input