File tree Expand file tree Collapse file tree 2 files changed +79
-36
lines changed Expand file tree Collapse file tree 2 files changed +79
-36
lines changed Original file line number Diff line number Diff line change 1
1
export interface TeamsPayload {
2
- '@type' : string ;
3
- '@context' : string ;
4
- themeColor : string ;
5
- title : string ;
6
- summary : string ;
7
- text ?: string ;
8
- sections ?: Section [ ] ;
9
- potentialAction ?: Action [ ] ;
2
+ type : string ;
3
+ attachments : Attachment [ ] ;
10
4
}
11
5
12
- interface Section {
13
- facts : Fact [ ] ;
6
+ interface Attachment {
7
+ contentType : string ;
8
+ contentUrl : unknown ;
9
+ content : AdaptiveCard ;
10
+ }
11
+
12
+ interface AdaptiveCard {
13
+ $schema : string ;
14
+ type : string ;
15
+ version : string ;
16
+ body : Element [ ] ;
17
+ actions : Action [ ] ;
18
+ }
19
+
20
+ type Element = TextBlock | FactSet | ActionSet | ColumnSet | Column ;
21
+
22
+ interface TextBlock {
23
+ type : 'TextBlock' ;
24
+ text : string ;
25
+ weight ?: 'default' | 'lighter' | 'bolder' ;
26
+ size ?: 'default' | 'small' | 'medium' | 'large' | 'extraLarge' ;
14
27
}
15
28
16
29
interface Fact {
17
- name : string ;
30
+ title : string ;
18
31
value : string ;
19
32
}
20
33
21
- interface Action {
22
- '@type' : string ;
23
- name : string ;
24
- targets : Target [ ] ;
34
+ interface FactSet {
35
+ type : 'FactSet' ;
36
+ facts : Fact [ ] ;
37
+ }
38
+
39
+ interface ActionSet {
40
+ type : 'ActionSet' ;
41
+ actions : Action [ ] ;
42
+ }
43
+
44
+ interface ColumnSet {
45
+ type : 'ColumnSet' ;
46
+ columns : Column [ ] ;
25
47
}
26
48
27
- interface Target {
28
- os : string ;
29
- uri : string ;
49
+ interface Column {
50
+ type : 'ColumnSet' ;
51
+ items : Element [ ] ;
52
+ }
53
+
54
+ interface Action {
55
+ type : string ;
56
+ title : string ;
57
+ url : string ;
30
58
}
Original file line number Diff line number Diff line change @@ -9,26 +9,41 @@ export const normalizeTeamsPayload = (
9
9
buttons : Button [ ]
10
10
) : TeamsPayload => {
11
11
return {
12
- '@type' : 'MessageCard' ,
13
- '@context' : 'https://schema.org/extensions' ,
14
- themeColor : color ,
15
- summary : title ,
16
- title,
17
- text,
18
- sections : [
12
+ type : 'message' ,
13
+ attachments : [
19
14
{
20
- facts : fields ,
15
+ contentType : 'application/vnd.microsoft.card.adaptive' ,
16
+ contentUrl : null ,
17
+ content : {
18
+ $schema :
19
+ 'http://adaptivecards.io/schemas/adaptive-card.json' ,
20
+ type : 'AdaptiveCard' ,
21
+ version : '1.2' ,
22
+ body : [
23
+ {
24
+ type : 'TextBlock' ,
25
+ text : title ,
26
+ size : 'large' ,
27
+ } ,
28
+ {
29
+ type : 'TextBlock' ,
30
+ text : text ,
31
+ } ,
32
+ {
33
+ type : 'FactSet' ,
34
+ facts : fields . map ( ( { name, value } ) => ( {
35
+ title : name ,
36
+ value,
37
+ } ) ) ,
38
+ } ,
39
+ ] ,
40
+ actions : buttons . map ( ( { label, url } ) => ( {
41
+ type : 'Action.OpenUrl' ,
42
+ title : label ,
43
+ url : url ,
44
+ } ) ) ,
45
+ } ,
21
46
} ,
22
47
] ,
23
- potentialAction : buttons . map ( ( button ) => ( {
24
- '@type' : 'OpenUri' ,
25
- name : button . label ,
26
- targets : [
27
- {
28
- os : 'default' ,
29
- uri : button . url ,
30
- } ,
31
- ] ,
32
- } ) ) ,
33
48
} ;
34
49
} ;
You can’t perform that action at this time.
0 commit comments