You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -28,37 +28,42 @@ In this quickstart, you learn how to:
28
28
29
29
- An Azure account and an active subscription. Create an [account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
30
30
-[Visual Studio 2019 or later](https://visualstudio.microsoft.com/vs/).
31
-
- The latest version of .NET Core. In this quickstart, we use [.NET Core 3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1). Be sure to install the version that corresponds with your instance of Visual Studio, 32-bit or 64-bit.
31
+
- The latest version of .NET Core. (https://dotnet.microsoft.com/download/dotnet/).
To use Azure Communication Services chat as a channel in Azure Bot Service, first deploy a bot. To deploy a bot, you complete these steps:
37
37
38
-
- Create an Azure Bot Service resource
39
-
- Get the bot's app ID and password
40
-
- Create a web app to hold the bot logic
41
-
- Create a messaging endpoint for the bot
38
+
-[Create an Azure Bot Service resource](#create-an-azure-bot-service-resource)
39
+
-[Get the bot's app ID and password](#get-the-bots-app-id-and-app-password)
40
+
-[Create a web app to hold the bot app](#create-a-web-app-to-hold-the-bot-app)
41
+
-[Create a messaging endpoint for the bot](#create-a-messaging-endpoint-for-the-bot)
42
42
43
43
### Create an Azure Bot Service resource
44
44
45
-
First, [use the Azure portal to create an Azure Bot Service resource](/azure/bot-service/abs-quickstart?tabs=userassigned). Communication Services Chat channel supports single-tenant bots, managed identity bots, and multi-tenant bots. For the purposes of this quickstart we will use a *multi-tenant* bot.
45
+
First, [use the Azure portal to create an Azure Bot Service resource](/azure/bot-service/abs-quickstart?tabs=userassigned). Communication Services Chat channel supports single-tenant bots, managed identity bots, and multitenant bots.
46
46
47
-
To set up a single-tenant or managed identity bot, review [Bot identity information](/azure/bot-service/bot-builder-authentication?tabs=userassigned%2Caadv2%2Ccsharp#bot-identity-information).
48
-
49
-
For a managed identity bot, you might have to [update the bot service identity](/azure/bot-service/bot-builder-authentication?tabs=userassigned%2Caadv2%2Ccsharp#to-update-your-app-service).
47
+
- For the purposes of this quickstart we will use a `multitenant`bot.
48
+
- To set up a `single-tenant` or `managed identity` bot, review [Bot identity information](/azure/bot-service/bot-builder-authentication?tabs=userassigned%2Caadv2%2Ccsharp#bot-identity-information).
49
+
-For a `managed identity` bot, you might have to [update the bot service identity](/azure/bot-service/bot-builder-authentication?tabs=userassigned%2Caadv2%2Ccsharp#to-update-your-app-service).
50
50
51
51
### Get the bot's app ID and app password
52
52
53
53
Next, [get the Microsoft app ID and password](/azure/bot-service/abs-quickstart?tabs=userassigned#to-get-your-app-or-tenant-id) that are assigned to your bot when it's deployed. You use these values for later configurations.
54
54
55
-
### Create a web app to hold the bot logic
55
+
### Create a bot app and publish it to a web app
56
56
57
-
To create a web app for your bot, you can revise [Bot Builder samples](https://github.com/Microsoft/BotBuilder-Samples) for your scenario or use the [Bot Builder SDK](/composer/introduction) to create a web app. One of the simplest samples is [Echo Bot](https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/02.echo-bot).
57
+
To create a bot you can do one of the following:
58
58
59
-
Azure Bot Service typically expects the Bot Application Web App Controller to expose an endpoint in the form `/api/messages`. The endpoint handles all messages that are sent to the bot.
59
+
- Revise [Bot Builder samples](https://github.com/Microsoft/BotBuilder-Samples) for your scenario, create a web app, and then deploy your bot sample to it.
60
+
- Use the [Bot Builder SDK](/composer/introduction) to create and publish a bot to a web app.
61
+
62
+
For this quickstart we will use the [Echo Bot](https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/02.echo-bot) sample from the Bot Builder samples.
60
63
61
-
To create the bot app, either use the Azure CLI to [create an Azure App Service resource](/azure/bot-service/provision-app-service?tabs=singletenant%2Cexistingplan) or create the app in the Azure portal.
64
+
#### Create a web app to hold the bot app
65
+
66
+
To create the web app, either use the Azure CLI to [create an Azure App Service resource](/azure/bot-service/provision-app-service?tabs=singletenant%2Cexistingplan) or create the app in the Azure portal.
62
67
63
68
To create a bot web app by using the Azure portal:
64
69
@@ -76,7 +81,9 @@ To create a bot web app by using the Azure portal:
76
81
77
82
:::image type="content" source="./media/web-app-endpoint.png" alt-text="Screenshot that shows how to copy the web app endpoint URL.":::
78
83
79
-
### Create a messaging endpoint for the bot
84
+
#### Create a messaging endpoint for the bot
85
+
86
+
Azure Bot Service typically expects the Bot Application Web App Controller to expose an endpoint in the form `/api/messages`. The endpoint handles all messages that are sent to the bot.
80
87
81
88
Next, in the bot resource, create a web app messaging endpoint:
82
89
@@ -88,9 +95,9 @@ Next, in the bot resource, create a web app messaging endpoint:
88
95
89
96
:::image type="content" source="./media/smaller-bot-configure-with-endpoint.png" alt-text="Screenshot that shows how to create a bot messaging endpoint by using the web app hostname." lightbox="./media/bot-configure-with-endpoint.png":::
90
97
91
-
### Deploy the web app
98
+
####Deploy the web app
92
99
93
-
The final step to create a bot is to deploy the web app. For this quickstart, use the Echo Bot sample. The Echo Bot functionality is limited to echoing the user input. Here's how you deploy it to your web app in Azure:
100
+
The final step to create a bot is to deploy the web app. For this quickstart, use the [Echo Bot](https://github.com/microsoft/BotBuilder-Samples/tree/main/samples/csharp_dotnetcore/02.echo-bot) sample. The Echo Bot functionality is limited to echoing the user input. Here's how you deploy it to your web app in Azure:
94
101
95
102
1. Use Git to clone this GitHub repository:
96
103
@@ -105,12 +112,14 @@ The final step to create a bot is to deploy the web app. For this quickstart, us
105
112
106
113
```json
107
114
{
115
+
"MicrosoftAppType": "",
108
116
"MicrosoftAppId": "<App-registration-ID>",
109
-
"MicrosoftAppPassword": "<App-password>"
117
+
"MicrosoftAppPassword": "<App-password>",
118
+
"MicrosoftAppTenantId": ""
110
119
}
111
120
```
112
121
113
-
Next, use Visual Studio for C# bots to deploy the bot.
122
+
Next, use Visual Studio or VS Code for C# bots to deploy the bot.
114
123
115
124
You also can use a Command Prompt window to [deploy an Azure bot](/azure/bot-service/provision-and-publish-a-bot?tabs=userassigned%2Ccsharp).
116
125
@@ -162,142 +171,30 @@ When you have a Communication Services resource, you can set up a Communication
162
171
163
172
Now that you have the bot's Communication Services ID, you can create a chat thread with the bot as a participant.
164
173
165
-
### Create a new C# application
174
+
### Follow the 'Add Chat to your app' quickstart
166
175
167
-
1. Run the following command to create a C# application:
176
+
Follow the steps in the [Add Chat to your app](/azure/communication-services/quickstarts/chat/get-started?pivots=programming-language-csharp) quickstart to create a chat app.
168
177
169
-
```console
170
-
dotnet new console -o ChatQuickstart
171
-
```
178
+
1. Replace <Resource_Endpoint> with the Communication Services endpoint from the [Get a Communication Service Resource](#get-a-communication-services-resource) step.
179
+
1. Replace <Access_Token> with the user access token from the [Get a Communication Service Resource](#get-a-communication-services-resource) step.
180
+
1. Replace <Access_ID> with the bots ACS_ID from the [Enable the Communication Services Chat channel](#enable-the-communication-services-chat-channel) step.
172
181
173
-
1. Change your directory to the new app folder and use the `dotnet build` command to compile your application:
182
+
### Run the C# chat application locally
174
183
175
-
```console
176
-
cd ChatQuickstart
177
-
dotnet build
178
-
```
179
-
180
-
### Install the package
181
-
182
-
Install the Communication Services Chat SDK for .NET:
184
+
To run the chat application locally, use the `dotnet run` command:
183
185
184
186
```powershell
185
-
dotnet add package Azure.Communication.Chat
186
-
```
187
-
188
-
### Create a chat client
189
-
190
-
To create a chat client, use your Communication Services endpoint and the user access token you generated earlier. Use the `CommunicationIdentityClient` class from the Identity SDK to create a user and issue a token to pass to your chat client. Access tokens can be generated in the portal using the following [instructions](/azure/communication-services/quickstarts/identity/access-tokens).
191
-
192
-
Copy the following code and paste it in the *Program.cs* source file:
Check the list of messages for the bot's echo reply to "Hello World".
190
+
You should receive a message from the bot in the console that says "Hello World".
268
191
269
-
You can use JavaScript or the Azure mobile SDKs to subscribe to incoming message notifications:
270
-
271
-
```javascript
272
-
// Open notifications channel
273
-
awaitchatClient.startRealtimeNotifications();
274
-
// Subscribe to new notifications
275
-
chatClient.on("chatMessageReceived", (e) => {
276
-
console.log("Notification chatMessageReceived!");
277
-
// Your code here
278
-
});
279
-
```
192
+
Example output:
280
193
281
-
### Clean up the chat thread
282
-
283
-
When you're finished using the chat thread, delete the thread:
284
-
285
-
```csharp
286
-
chatClient.DeleteChatThread(threadId);
194
+
```powershell
195
+
1730405535010:Hello World
287
196
```
288
197
289
-
### Deploy the C# chat application
290
-
291
-
To deploy the chat application:
292
-
293
-
1. In Visual Studio, open the chat project.
294
-
295
-
1. Right-click the **ChatQuickstart** project and select **Publish**:
296
-
297
-
:::image type="content" source="./media/deploy-chat-application.png" alt-text="Screenshot that shows deploying the chat application to Azure from Visual Studio.":::
298
-
299
-
1. Once you publish the solution, run it and check if Echobot echoes the user message on the command prompt. Now that you have the solution you can proceed to play with the various activities that are needed for the business scenarios that you need to solve for.
300
-
301
198
## More things you can do with a bot
302
199
303
200
A bot can receive more than a plain-text message from a user in a Communications Services Chat channel. Some of the activities a bot can receive from a user include:
@@ -560,7 +457,3 @@ Verify that the bot's Microsoft app ID and password are saved correctly in the b
560
457
### Bot can't be added as a participant
561
458
562
459
Verify that the bot's Communication Services ID is used correctly when a request is sent to add a bot to a chat thread.
563
-
564
-
## Next steps
565
-
566
-
Try the [chat bot demo app](https://github.com/Azure/communication-preview/tree/master/samples/AzureBotService-Sample-App) for a 1:1 chat between a chat user and a bot via the BotFramework WebChat UI component.
0 commit comments