8000 Merge pull request #91 from Microsoft/v-stgum/samples · Pucadopr/botbuilder-python@cdda8ae · GitHub
[go: up one dir, main page]

Skip to content

Commit cdda8ae

Browse files
authored
Merge pull request microsoft#91 from Microsoft/v-stgum/samples
add simple Rich-Cards-Bot sample
2 parents efd8b30 + f9bdf61 commit cdda8ae

File tree

6 files changed

+531
-2
lines changed

6 files changed

+531
-2
lines changed

samples/EchoBot-with-State/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ git clone https://github.com/Microsoft/botbuilder-python.git
88

99

1010
### Visual studio code
11-
- open `botbuilder-python\samples\EchoBot-with-State` folder
11+
- Activate your desired virtual environment
12+
- Open `botbuilder-python\samples\EchoBot-with-State` folder
1213
- Bring up a terminal, navigate to `botbuilder-python\samples\EchoBot-with-State` folder
13-
- type 'python main.py'
14+
- In the terminal, type `pip install -r requirements.txt`
15+
- In the terminal, type `python main.py`
1416

1517
## Testing the bot using Bot Framework Emulator
1618
[Microsoft Bot Framework Emulator](https://github.com/microsoft/botframework-emulator) is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.

samples/Rich-Cards-Bot/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Rich Cards Bot
2+
3+
Bots support multi-modal conversations so you can add media to messages sent by the bot to the user.
4+
5+
This sample shows how to use different types of rich cards.
6+
7+
## To try this sample
8+
- Clone the repository
9+
```bash
10+
git clone https://github.com/Microsoft/botbuilder-python.git
11+
```
12+
13+
### Visual studio code
14+
- Activate your desired virtual environment
15+
- Open `botbuilder-python\samples\Rich-Cards-Bot` folder
16+
- Bring up a terminal, navigate to `botbuilder-python\samples\Rich-Cards-Bot` folder
17+
- In the terminal, type `pip install -r requirements.txt`
18+
- In the terminal, type `python main.py`
19+
20+
21+
## Testing the bot using Bot Framework Emulator
22+
[Microsoft Bot Framework Emulator](https://github.com/microsoft/botframework-emulator) is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.
23+
24+
- Install the Bot Framework emulator from [here](https://github.com/Microsoft/BotFramework-Emulator/releases)
25+
26+
### Connect to bot using Bot Framework Emulator **V4**
27+
- Launch Bot Framework Emulator
28+
- File -> Open bot and navigate to samples\Rich-Cards-Bot folder
29+
- Select Rich-Cards-Bot.bot file
30+
31+
### Connect to bot using Bot Framework Emulator **V3**
32+
- Launch Bot Framework Emulator
33+
- Paste this URL in the emulator window - http://localhost:9000/api/messages
34+
35+
# Adding media to messages
36+
A message exchange between user and bot can contain media attachments, such as cards, images, video, audio, and files.
37+
38+
There are several different card types supported by Bot Framework including:
39+
- [Adaptive card](http://adaptivecards.io)
40+
- [Hero card](https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#herocard-object)
41+
- [Thumbnail card](https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0#thumbnailcard-object)
42+
- [More...](https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-add-rich-cards?view=azure-bot-service-4.0)
43+
44+
# Further reading
45+
46+
- [Azure Bot Service Introduction](https://docs.microsoft.com/en-us/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0)
47+
- [Bot State](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-storage-concept?view=azure-bot-service-4.0)
48+
- [Add media to messages](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-howto-add-media-attachments?view=azure-bot-service-4.0&tabs=csharp)
49+
- [Rich card types](https://docs.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-add-rich-cards?view=azure-bot-service-4.0)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "Rich-Cards-Bot",
3+
"secretKey": "",
4+
"services": [
5+
{
6+
"appId": "",
7+
"id": "http://localhost:9000",
8+
"type": "endpoint",
9+
"appPassword": "",
10+
"endpoint": "http://localhost:9000",
11+
"name": "Rich-Cards-Bot"
12+
}
13+
]
14+
}
Lines changed: 208 additions & 0 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
"""Example content for an AdaptiveCard."""
4+
5+
ADAPTIVE_CARD_CONTENT = {
6+
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
7+
"version": "1.0",
8+
"type": "AdaptiveCard",
9+
"speak": "Your flight is confirmed for you and 3 other passengers from San Francisco to Amsterdam on Friday, October 10 8:30 AM",
10+
"body": [
11+
{
12+
"type": "TextBlock",
13+
"text": "Passengers",
14+
"weight": "bolder",
15+
"isSubtle": False
16+
},
17+
{
18+
"type": "TextBlock",
19+
"text": "Sarah Hum",
20+
"separator": True
21+
},
22+
{
23+
"type": "TextBlock",
24+
"text": "Jeremy Goldberg",
25+
"spacing": "none"
26+
},
27+
{
28+
"type": "TextBlock",
29+
"text": "Evan Litvak",
30+
"spacing": "none"
31+
},
32+
{
33+
"type": "TextBlock",
34+
"text": "2 Stops",
35+
"weight": "bolder",
36+
"spacing": "medium"
37+
},
38+
{
39+
"type": "TextBlock",
40+
"text": "Fri, October 10 8:30 AM",
41+
"weight": "bolder",
42+
"spacing": "none"
43+
},
44+
{
45+
"type": "ColumnSet",
46+
"separator": True,
47+
"columns": [
48+
{
49+
"type": "Column",
50+
"width": 1,
51+
"items": [
52+
{
53+
"type": "TextBlock",
54+
"text": "San Francisco",
55+
"isSubtle": True
56+
},
57+
{
58+
"type": "TextBlock",
59+
"size": "extraLarge",
60+
"color": "accent",
61+
"text": "SFO",
62+
"spacing": "none"
63+
}
64+
]
65+
},
66+
{
67+
"type": "Column",
68+
"width": "auto",
69+
"items": [
70+
{
71+
"type": "TextBlock",
72+
"text": " "
73+
},
74+
{
75+
"type": "Image",
76+
"url": "http://messagecardplayground.azurewebsites.net/assets/airplane.png",
77+
"size": "small",
78+
"spacing": "none"
79+
}
80+
]
81+
},
82+
{
83+
"type": "Column",
84+
"width": 1,
85+
"items": [
86+
{
87+
"type": "TextBlock",
88+
"horizontalAlignment": "right",
89+
"text": "Amsterdam",
90+
"isSubtle": True
91+
},
92+
{
93+
"type": "TextBlock",
94+
"horizontalAlignment": "right",
95+
"size": "extraLarge",
96+
"color": "accent",
97+
"text": "AMS",
98+
"spacing": "none"
99+
}
100+
]
101+
}
102+
]
103+
},
104+
{
105+
"type": "TextBlock",
106+
"text": "Non-Stop",
107+
"weight": "bolder",
108+
"spacing": "medium"
109+
},
110+
{
111+
"type": "TextBlock",
112+
"text": "Fri, October 18 9:50 PM",
113+
"weight": "bolder",
114+
"spacing": "none"
115+
},
116+
{
117+
"type": "ColumnSet",
118+
"separator": True,
119+
"columns": [
120+
{
121+
"type": "Column",
122+
"width": 1,
123+
"items": [
124+
{
125+
"type": "TextBlock",
126+
"text": "Amsterdam",
127+
"isSubtle": True
128+
},
129+
{
130+
"type": "TextBlock",
131+
"size": "extraLarge",
132+
"color": "accent",
133+
"text": "AMS",
134+
"spacing": "none"
135+
}
136+
]
137+
},
138+
{
139+
"type": "Column",
140+
"width": "auto",
141+
"items": [
142+
{
143+
"type": "TextBlock",
144+
"text": " "
145+
},
146+
{
147+
"type": "Image",
148+
"url": "http://messagecardplayground.azurewebsites.net/assets/airplane.png",
149+
"size": "small",
150+
"spacing": "none"
151+
}
152+
]
153+
},
154+
{
155+
"type": "Column",
156+
"width": 1,
157+
"items": [
158+
{
159+
"type": "TextBlock",
160+
"horizontalAlignment": "right",
161+
"text": "San Francisco",
162+
"isSubtle": True
163+
},
164+
{
165+
"type": "TextBlock",
166+
"horizontalAlignment": "right",
167+
"size": "extraLarge",
168+
"color": "accent",
169+
"text": "SFO",
170+
"spacing": "none"
171+
}
172+
]
173+
}
174+
]
175+
},
176+
{
177+
"type": "ColumnSet",
178+
"spacing": "medium",
179+
"columns": [
180+
{
181+
"type": "Column",
182+
"width": "1",
183+
"items": [
184+
{
185+
"type": "TextBlock",
186+
"text": "Total",
187+
"size": "medium",
188+
"isSubtle": True
189+
}
190+
]
191+
},
192+
{
193+
"type": "Column",
194+
"width": 1,
195+
"items": [
196+
{
197+
"type": "TextBlock",
198+
"horizontalAlignment": "right",
199+
"text": "$4,032.54",
200+
"size": "medium",
201+
"weight": "bolder"
202+
}
203+
]
204+
}
205+
]
206+
}
207+
]
208+
}

0 commit comments

Comments
 (0)
0