Message class
可簡化使用附件建置複雜訊息的訊息產生器類別。
建構函式
| Message(Session) | 建立新的訊息產生器。 |
方法
建構函式詳細資料
Message(Session)
方法詳細資料
addAttachment(AttachmentType)
將附件新增至訊息。 如需範例,請參閱 IAttachment。
function addAttachment(attachment: AttachmentType)
參數
- attachment
- AttachmentType
要加入的附件。
傳回
addEntity(Object)
address(IAddress)
attachmentLayout(string)
attachments(AttachmentType[])
code(string)
compose(string[][], any[])
撰寫複雜且隨機的回復給使用者。
function compose(prompts: string[][], args: any[])
參數
- prompts
-
string[][]
- args
-
any[]
傳回
composePrompt(Session, string[][], any[])
改用 compose()。
function composePrompt(session: Session, prompts: string[][], args: any[])
參數
- session
- Session
- prompts
-
string[][]
- args
-
any[]
傳回
composePrompt(Session, string[][], any[])
將提示數位結合成單一當地語系化提示,然後選擇性地以傳入的自變數填入提示範本位置。
static function composePrompt(session: Session, prompts: string[][], args?: any[])
參數
- session
- Session
用來本地化個別提示元件的會話物件。
- prompts
-
string[][]
提示清單的陣列。 陣列中的每個專案都是另一個會隨機選擇的提示陣列。 合併的輸出文字將會以空格分隔。
- args
-
any[]
(選擇性) 自變數陣列,用來在提示為範本時格式化輸出文字。
傳回
string
entities(Object[])
inputHint(string)
用戶端提示,讓他們知道 Bot 是否預期進一步輸入。 內建提示會自動為傳出訊息填入此值。
function inputHint(hint: string)
參數
- hint
-
string
傳回
localTimestamp(string)
傳送訊息的當地時間(由用戶端或 Bot 設定,例如:2016-09-23T13:07:49.4714686-07:00。
function localTimestamp(time?: string)
參數
- time
-
string
(選擇性) 時間,以 ISO 字串表示。 預設為 new Date().toISOString()。
傳回
name(string)
nspeak(TextType, TextType, number)
有條件地設定指定計數之訊息的說話欄位。
function nspeak(ssml: TextType, ssml_plural: TextType, count: number)
參數
- ssml
- TextType
- ssml_plural
- TextType
- count
-
number
傳回
ntext(TextType, TextType, number)
有條件地設定指定計數的訊息文字。
function ntext(msg: TextType, msg_plural: TextType, count: number)
參數
- msg
- TextType
- msg_plural
- TextType
- count
-
number
傳回
originalEvent(any)
randomPrompt(TextType)
隨機選取提示。
static function randomPrompt(prompts: TextType)
參數
- prompts
- TextType
要從中選擇的提示陣列。 當提示類型為 字串時, 只會傳回未修改的提示。
傳回
string
relatesTo(IAddress)
setChannelData(any)
setLanguage(string)
setNText(Session, string, string, number)
已被取代 改用 ntext() ntext()。
function setNText(session: Session, msg: string, msg_plural: string, count: number)
參數
- session
- Session
- msg
-
string
- msg_plural
-
string
- count
-
number
傳回
setText(Session, TextType, any[])
已被取代 改為使用 text()。
function setText(session: Session, prompt: TextType, args: any[])
參數
- session
- Session
- prompt
- TextType
- args
-
any[]
傳回
sourceEvent(ISourceEventMap)
speak(TextType, any[])
標 記語言 (SSML)。 這會在支持的裝置上與使用者交談。
function speak(ssml: TextType, args: any[])
參數
- ssml
- TextType
- args
-
any[]
傳回
suggestedActions(ISuggestedActions | IIsSuggestedActions)
要傳送給用戶的選擇性建議動作。 建議的動作只會顯示在支持建議動作的通道上。
function suggestedActions(suggestedActions: ISuggestedActions | IIsSuggestedActions)
參數
- suggestedActions
傳回
summary(TextType, any[])
要以後援方式顯示的文字,以及訊息內容的簡短描述,例如最近的交談清單。
function summary(text: TextType, args: any[])
參數
- text
- TextType
- args
-
any[]