-
Notifications
You must be signed in to change notification settings - Fork 6
/
InvokeResponseFactory.yml
132 lines (119 loc) · 4.27 KB
/
InvokeResponseFactory.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
### YamlMime:TSType
name: InvokeResponseFactory
uid: '@microsoft/teamsfx.InvokeResponseFactory'
package: '@microsoft/teamsfx'
summary: >-
Provides methods for formatting various invoke responses a bot can send to
respond to an invoke request.
fullName: InvokeResponseFactory
remarks: |-
All of these functions return an `InvokeResponse` object, which can be
passed as input to generate a new `invokeResponse` activity.
This example sends an invoke response that contains an adaptive card.
```typescript
const myCard = {
type: "AdaptiveCard",
body: [
{
"type": "TextBlock",
"text": "This is a sample card"
}],
$schema: "http://adaptivecards.io/schemas/adaptive-card.json",
version: "1.4"
};
const invokeResponse = InvokeResponseFactory.adaptiveCard(myCard);
await context.sendActivity({
type: ActivityTypes.InvokeResponse,
value: invokeResponse,
});
```
isDeprecated: false
type: class
methods:
- name: adaptiveCard(unknown)
uid: '@microsoft/teamsfx.InvokeResponseFactory.adaptiveCard'
package: '@microsoft/teamsfx'
summary: >-
Create an invoke response from an adaptive card.
The type of the invoke response is
`application/vnd.microsoft.card.adaptive` indicates
the request was successfully processed, and the response includes an
adaptive card
that the client should display in place of the current one.
remarks: ''
isDeprecated: false
syntax:
content: 'static function adaptiveCard(card: unknown): InvokeResponse<any>'
parameters:
- id: card
type: unknown
description: The adaptive card JSON payload.
return:
description: An `InvokeResponse` object.
type: InvokeResponse<any>
- name: createInvokeResponse(StatusCodes, unknown)
uid: '@microsoft/teamsfx.InvokeResponseFactory.createInvokeResponse'
package: '@microsoft/teamsfx'
summary: Create an invoke response with status code and response value.
remarks: ''
isDeprecated: false
syntax:
content: >-
static function createInvokeResponse(statusCode: StatusCodes, body?:
unknown): InvokeResponse<any>
parameters:
- id: statusCode
type: StatusCodes
description: The status code.
- id: body
type: unknown
description: The value of the response body.
return:
description: An `InvokeResponse` object.
type: InvokeResponse<any>
- name: errorResponse(InvokeResponseErrorCode, string)
uid: '@microsoft/teamsfx.InvokeResponseFactory.errorResponse'
package: '@microsoft/teamsfx'
summary: >-
Create an invoke response with error code and message.
The type of the invoke response is `application/vnd.microsoft.error`
indicates
the request was failed to processed.
remarks: ''
isDeprecated: false
syntax:
content: >-
static function errorResponse(errorCode: InvokeResponseErrorCode,
errorMessage: string): InvokeResponse<any>
parameters:
- id: errorCode
type: <xref uid="@microsoft/teamsfx.InvokeResponseErrorCode" />
description: |-
The status code indicates error, available values:
- 400 (BadRequest): indicate the incoming request was invalid.
- 500 (InternalServerError): indicate an unexpected error occurred.
- id: errorMessage
type: string
description: The error message.
return:
description: An `InvokeResponse` object.
type: InvokeResponse<any>
- name: textMessage(string)
uid: '@microsoft/teamsfx.InvokeResponseFactory.textMessage'
package: '@microsoft/teamsfx'
summary: >-
Create an invoke response from a text message.
The type of the invoke response is
`application/vnd.microsoft.activity.message`
indicates the request was successfully processed.
remarks: ''
isDeprecated: false
syntax:
content: 'static function textMessage(message: string): InvokeResponse<any>'
parameters:
- id: message
type: string
description: A text message included in a invoke response.
return:
description: An `InvokeResponse` object.
type: InvokeResponse<any>