# Class: Response

## Response(request, session, nlu)

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

## Constructor

#### new Response(request, session, nlu)

##### Parameters:

Name | Type | Description
--- | --- | ---
`request` | Requset | 请求
`session` | Session | session
`nlu` | Nlu | query解析对象

Source:
  - Response.js, line 29

### Methods

#### build(data) → {Promise}

打包返回的结果

##### Parameters:

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

Source:
  - Response.js, line 103

##### Returns:

Type
  Promise

##### Example

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

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

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

#### illegalRequest() → {Promise}

非法请求

Source:
  - Response.js, line 67

##### Returns:

Type
  Promise

#### setShouldEndSession(val)

设置结束对话

##### Parameters:

Name | Type | Description
--- | --- | ---
`val` | boolean | true: 结束对话 false: 继续对话

Source:
  - Response.js, line 48