Skip to content

Latest commit

 

History

History
141 lines (101 loc) · 4.53 KB

Response.md

File metadata and controls

141 lines (101 loc) · 4.53 KB

Response

按照Bot协议,打包返回结果

Kind: global class

new Response(request, session, nlu)

构造方法

Param Type Description
request Request 请求
session Session session
nlu Nlu query解析对象

response.setShouldEndSession(val)

设置结束对话

Kind: instance method of Response

Param Type Description
val boolean true: 结束对话,false: 继续对话

response.setExpectSpeech(expectSpeech)

通过控制expectSpeech来控制麦克风开关

Kind: instance method of Response

Param Type Description
expectSpeech boolean 麦克风是否开启

response.illegalRequest() ⇒ Promise

非法请求

Kind: instance method of Response

response.build(data) ⇒ Promise

打包返回的结果

Kind: instance method of Response
Access: public

Param Type Description
data Object 返回的数据
data.directives Array 返回的指令
data.card BaseCard 返回的卡片
data.outputSpeech string | Object 返回的tts文本。可以是纯文本,或者是有SSML标签的文本(TODO:SSML说明文档)
data.reprompt string | Object 纯文本或者带SSML标签的文本

Example

this.build({
     'outputSpeech' : '你好',
     'reprompt' : '再请问一次,你是要干嘛呢'
});

this.build({
     'card' : new TextCard('欢迎进入')
});

this.build({
     // 与 'outputSpeech' : '你好', 效果一样
     'outputSpeech' : {
         'type':'PlainText',
         'text': '你好'
     }
});

response.setNeedDetermine()

设置needDetermine为true

Kind: instance method of Response

response.setFallBack()

表示本次返回的结果是否为兜底结果

Kind: instance method of Response

response.setAutoDirectivesArrangement()

表示directives中指令顺序随机

Kind: instance method of Response

response.setStrictDirectivesArrangement()

表示directives中指令保持相对顺序不变 (directives中指令可能会被过滤)

Kind: instance method of Response

response.addExpectTextResponse(text)

技能所期待的用户回复,技能将该信息反馈给DuerOS,有助于DuerOS在语音识别以及识别纠错时向该信息提权。

Kind: instance method of Response

Param Type Description
text string 普通文本内容类型回复表达的回复内容。

response.addExpectSlotResponse(slot)

技能所期待的用户回复,技能将该信息反馈给DuerOS,有助于DuerOS在语音识别以及识别纠错时向该信息提权。

Kind: instance method of Response

Param Type Description
slot string 槽位类型回复表达的槽位名称。