CardFactory class
Fornisce metodi per la formattazione dei vari tipi di scheda che un bot può restituire.
Commenti
Tutte queste funzioni restituiscono un oggetto Attachment, che può essere aggiunto agli allegati di un'attività esistente raccolta direttamente o passata come input a uno dei metodi di MessageFactory per generare una nuova attività.
In questo esempio viene inviato un messaggio contenente una singola scheda hero.
const { MessageFactory, CardFactory } = require('botbuilder');
const card = CardFactory.heroCard(
'White T-Shirt',
['https://example.com/whiteShirt.jpg'],
['buy']
);
const message = MessageFactory.attachment(card);
await context.sendActivity(message);
Proprietà
| content |
Elenca lo schema del tipo di contenuto per ogni stile di scheda. |
Metodi
Dettagli proprietà
contentTypes
Elenca lo schema del tipo di contenuto per ogni stile di scheda.
static contentTypes: any
Valore della proprietà
any
Dettagli metodo
actions(string | CardAction[] | undefined)
Restituisce una matrice di azioni formattata correttamente.
static function actions(actions: string | CardAction[] | undefined): CardAction[]
Parametri
- actions
-
string | CardAction[] | undefined
Matrice di azioni da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
Restituisce
CardAction[]
Matrice di azioni formattata correttamente.
adaptiveCard(any)
Restituisce un allegato per una scheda adattiva.
static function adaptiveCard(card: any): Attachment
Parametri
- card
-
any
Descrizione della scheda adattiva da restituire.
Restituisce
Attachment
Un allegato.
Commenti
Le schede adattive sono un formato di scambio di schede aperto che consente agli sviluppatori di scambiare contenuto dell'interfaccia utente in modo comune e coerente. Per i canali che non supportano ancora le schede adattive in modo nativo, Bot Framework eseguirà il rendering della scheda in un'immagine con uno stile ottimale nel canale di destinazione. Per i canali che supportano schede hero puoi continuare a includere le azioni della scheda adattiva e verranno inviate come pulsanti insieme alla versione di cui è stato eseguito il rendering della scheda.
Per altre informazioni sulle schede adattive e per scaricare l'SDK più recente, visitare adaptivecards.io.
Per esempio:
const card = CardFactory.adaptiveCard({
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Default text input"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK"
}
]
});
animationCard(string, string | MediaUrl[], string | CardAction[], Partial<AnimationCard>)
Restituisce un allegato per una scheda di animazione.
static function animationCard(title: string, media: string | MediaUrl[], buttons?: string | CardAction[], other?: Partial<AnimationCard>): Attachment
Parametri
- title
-
string
Titolo della scheda.
- media
-
string | MediaUrl[]
URL multimediali per la scheda.
- buttons
-
string | CardAction[]
Opzionale. Matrice di pulsanti da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
- other
-
Partial<AnimationCard>
Opzionale. Eventuali proprietà aggiuntive da includere nella scheda.
Restituisce
Attachment
Un allegato.
audioCard(string, string | MediaUrl[], string | CardAction[], Partial<AudioCard>)
Restituisce un allegato per una scheda audio.
static function audioCard(title: string, media: string | MediaUrl[], buttons?: string | CardAction[], other?: Partial<AudioCard>): Attachment
Parametri
- title
-
string
Titolo della scheda.
- media
-
string | MediaUrl[]
URL multimediale per la scheda.
- buttons
-
string | CardAction[]
Opzionale. Matrice di pulsanti da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
- other
-
Partial<AudioCard>
Opzionale. Eventuali proprietà aggiuntive da includere nella scheda.
Restituisce
Attachment
Un allegato.
heroCard(string, string | CardImage[], string | CardAction[], Partial<HeroCard>)
Restituisce un allegato per una scheda hero.
static function heroCard(title: string, images?: string | CardImage[], buttons?: string | CardAction[], other?: Partial<HeroCard>): Attachment
Parametri
- title
-
string
Titolo della scheda.
- images
-
string | CardImage[]
Opzionale. Matrice di immagini da includere nella scheda. Ogni elemento può essere un CardImage o l'URL dell'immagine da includere.
- buttons
-
string | CardAction[]
Opzionale. Matrice di pulsanti da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
- other
-
Partial<HeroCard>
Opzionale. Eventuali proprietà aggiuntive da includere nella scheda.
Restituisce
Attachment
Un allegato.
Commenti
Le schede hero tendono ad avere un'immagine dominante e a larghezza intera. I canali in genere eseguono il rendering del testo e dei pulsanti della scheda sotto l'immagine.
Per esempio:
const card = CardFactory.heroCard(
'White T-Shirt',
['https://example.com/whiteShirt.jpg'],
['buy']
);
heroCard(string, string, string | CardImage[], string | CardAction[], Partial<HeroCard>)
Restituisce un allegato per una scheda hero.
static function heroCard(title: string, text: string, images?: string | CardImage[], buttons?: string | CardAction[], other?: Partial<HeroCard>): Attachment
Parametri
- title
-
string
Titolo della scheda.
- text
-
string
Testo della scheda.
- images
-
string | CardImage[]
Opzionale. Matrice di immagini da includere nella scheda. Ogni elemento può essere un CardImage o l'URL dell'immagine da includere.
- buttons
-
string | CardAction[]
Opzionale. Matrice di pulsanti da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
- other
-
Partial<HeroCard>
Opzionale. Eventuali proprietà aggiuntive da includere nella scheda.
Restituisce
Attachment
Un allegato.
Commenti
Le schede hero tendono ad avere un'immagine dominante e a larghezza intera. I canali in genere eseguono il rendering del testo e dei pulsanti della scheda sotto l'immagine. Per esempio:
const card = CardFactory.heroCard(
'White T-Shirt',
['https://example.com/whiteShirt.jpg'],
['buy']
);
images(string | CardImage[] | undefined)
Restituisce una matrice formattata correttamente di immagini di schede.
static function images(images: string | CardImage[] | undefined): CardImage[]
Parametri
- images
-
string | CardImage[] | undefined
Matrice di immagini da includere nella scheda. Ogni elemento può essere un CardImage o l'URL dell'immagine da includere.
Restituisce
CardImage[]
Matrice formattata correttamente di immagini di schede.
media(string | MediaUrl[] | undefined)
Restituisce una matrice formattata correttamente di oggetti URL multimediali.
static function media(links: string | MediaUrl[] | undefined): MediaUrl[]
Parametri
- links
-
string | MediaUrl[] | undefined
URL dei supporti. Ogni string viene convertita in un oggetto URL multimediale.
Restituisce
MediaUrl[]
Matrice formattata correttamente di oggetti URL multimediali.
o365ConnectorCard(O365ConnectorCard)
Restituisce un allegato per una scheda connettore di Office 365.
static function o365ConnectorCard(card: O365ConnectorCard): Attachment
Parametri
- card
-
O365ConnectorCard
descrizione della scheda connettore di Office 365 da restituire.
Restituisce
Attachment
Un allegato.
Commenti
Per esempio:
const card = CardFactory.o365ConnectorCard({
"title": "card title",
"text": "card text",
"summary": "O365 card summary",
"themeColor": "#E67A9E",
"sections": [
{
"title": "**section title**",
"text": "section text",
"activityTitle": "activity title",
}
]
});
oauthCard(string, string, string, string, TokenExchangeResource)
Restituisce un allegato per una scheda OAuth.
static function oauthCard(connectionName: string, title: string, text?: string, link?: string, tokenExchangeResource?: TokenExchangeResource): Attachment
Parametri
- connectionName
-
string
Nome della connessione OAuth da usare.
- title
-
string
Titolo del pulsante di accesso della scheda.
- text
-
string
Opzionale. Testo aggiuntivo da includere nella scheda.
- link
-
string
Opzionale. Collegamento di accesso da usare.
- tokenExchangeResource
-
TokenExchangeResource
opzionale. Risorsa con cui provare a eseguire lo scambio di token.
Restituisce
Attachment
Un allegato.
Commenti
Le schede OAuth supportano il servizio Single Sign-On (SSO) di Bot Framework.
receiptCard(ReceiptCard)
Restituisce un allegato per una scheda di ricevuta.
static function receiptCard(card: ReceiptCard): Attachment
Parametri
- card
-
ReceiptCard
Descrizione della scheda di ricezione da restituire.
Restituisce
Attachment
Un allegato.
signinCard(string, string, string)
Restituisce un allegato per una scheda di accesso.
static function signinCard(title: string, url: string, text?: string): Attachment
Parametri
- title
-
string
Titolo del pulsante di accesso della scheda.
- url
-
string
URL della pagina di accesso da usare.
- text
-
string
Opzionale. Testo aggiuntivo da includere nella scheda.
Restituisce
Attachment
Un allegato.
Commenti
Per i canali che non supportano in modo nativo le schede di accesso, viene eseguito il rendering di un messaggio alternativo.
thumbnailCard(string, string | CardImage[], string | CardAction[], Partial<ThumbnailCard>)
Restituisce un allegato per una scheda di anteprima.
static function thumbnailCard(title: string, images?: string | CardImage[], buttons?: string | CardAction[], other?: Partial<ThumbnailCard>): Attachment
Parametri
- title
-
string
Titolo della scheda.
- images
-
string | CardImage[]
Opzionale. Matrice di immagini da includere nella scheda. Ogni elemento può essere un CardImage o l'URL dell'immagine da includere.
- buttons
-
string | CardAction[]
Opzionale. Matrice di pulsanti da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
- other
-
Partial<ThumbnailCard>
Opzionale. Eventuali proprietà aggiuntive da includere nella scheda.
Restituisce
Attachment
Un allegato.
Commenti
Le schede di anteprima sono simili alle schede hero, ma invece di un'immagine a larghezza intera, vengono in genere sottoposte a rendering con una versione di anteprima più piccola dell'immagine. I canali in genere eseguono il rendering del testo della scheda su un lato dell'immagine, con tutti i pulsanti visualizzati sotto la scheda.
thumbnailCard(string, string, string | CardImage[], string | CardAction[], Partial<ThumbnailCard>)
Restituisce un allegato per una scheda di anteprima.
static function thumbnailCard(title: string, text: string, images?: string | CardImage[], buttons?: string | CardAction[], other?: Partial<ThumbnailCard>): Attachment
Parametri
- title
-
string
Titolo della scheda.
- text
-
string
Testo della scheda.
- images
-
string | CardImage[]
Opzionale. Matrice di immagini da includere nella scheda. Ogni elemento può essere un CardImage o l'URL dell'immagine da includere.
- buttons
-
string | CardAction[]
Opzionale. Matrice di pulsanti da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
- other
-
Partial<ThumbnailCard>
Opzionale. Eventuali proprietà aggiuntive da includere nella scheda.
Restituisce
Attachment
Un allegato.
Commenti
Le schede di anteprima sono simili alle schede hero, ma invece di un'immagine a larghezza intera, vengono in genere sottoposte a rendering con una versione di anteprima più piccola dell'immagine. I canali in genere eseguono il rendering del testo della scheda su un lato dell'immagine, con tutti i pulsanti visualizzati sotto la scheda.
videoCard(string, string | MediaUrl[], string | CardAction[], Partial<VideoCard>)
Restituisce un allegato per una scheda video.
static function videoCard(title: string, media: string | MediaUrl[], buttons?: string | CardAction[], other?: Partial<VideoCard>): Attachment
Parametri
- title
-
string
Titolo della scheda.
- media
-
string | MediaUrl[]
URL multimediali per la scheda.
- buttons
-
string | CardAction[]
Opzionale. Matrice di pulsanti da includere nella scheda. Ogni string nella matrice viene convertita in un pulsante imBack con un titolo e un valore impostati sul valore della stringa.
- other
-
Partial<VideoCard>
Opzionale. Eventuali proprietà aggiuntive da includere nella scheda.
Restituisce
Attachment
Un allegato.