Group Chat Sample
Overview
This is a sample application to show how we can use the @azure/communication-react
package to build a chat experience.
Learn more about the Azure Communication Services UI Library.
The client-side application is a React based user interface. Alongside this front-end is a NodeJS web application powered by ExpressJS that performs functionality like minting new user tokens for each chat participant.
Additional documentation for this sample can be found on Microsoft Docs.
❤️ Feedback
We appreciate your feedback and energy helping us improve our services. If you've tried the service, please give us feedback through this survey.
Prerequisites
- Visual Studio Code (Stable Build)
- Node.js (LTS version)
- Create an Azure account with an active subscription. For details, see Create an account for free.
- Create an Azure Communication Services resource. For details, see Create an Azure Communication Resource. You'll need to record your resource connection string for this quickstart.
Code structure
- ./Chat/src/app: Where the client code lives
- ./Chat/src/app/App.tsx: Entry point into the chat sample
- ./Chat/src/app/HomeScreen.tsx: The first screen in the chat sample
- ./Chat/src/app/ConfigurationScreen.tsx: Where to set your name and avatar for the chat
- ./Chat/src/app/ChatScreen.tsx: The main chat thread screen
- ./Chat/src/app/EndScreen.tsx: The screen the user will see when they are no longer in the chat thread
- ./Chat/src/app/ErrorScreen.tsx: The screen when an error occurs in the chat thread
- ./Server: server code
- ./Server/appsettings.json: Where to put your azure communication services connection string
Before running the sample for the first time
- Open an instance of PowerShell, Windows Terminal, Command Prompt or equivalent and navigate to the directory that you'd like to clone the sample to.
git clone https://github.com/Azure-Samples/communication-services-web-chat-hero.git
- Get the
Connection String
from the Azure portal. For more information on connection strings, see Create an Azure Communication Resources - Once you get the
Connection String
, Add the connection string to the Server/appsettings.json file found under the Chat folder. Input your connection string in the variable:ResourceConnectionString
. - Once you get the
Endpoint
, add the endpoint string to the Server/appsetting.json file. Input your endpoint in the variable:EndpointUrl
. - Get the
identity
from the Azure portal. Click onIdentities & User Access Tokens
in Azure portal. Generate a user withChat
scope. - Once you get the
identity
string, add the identity string to the Server/appsetting.json file. Input your identity string in the variable:AdminUserId
. This is the server user to add new users to the chat thread.
Local run
- Set your connection string in
Server/appsettings.json
- Set your endpoint URL string in
Server/appsettings.json
- Set your adminUserId string in
Server/appsettings.json
npm run setup
from the root directorynpm run start
from the root directory
Publish to Azure
npm run setup
npm run build
npm run package
- Use the Azure extension and deploy the
Chat/dist
directory to your app service
Data Collection
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. This hero sample collects information about users and their use of the software that cannot be opted out of. Do not use this sample if you wish to avoid telemetry. You can learn more about data collection and use in the help documentation and Microsoft’s privacy statement. For more information on the data collected by the Azure SDK, please visit the Telemetry Policy page.
Additional Reading
- Azure Communication Services - UI Library - To learn more about what the
@azure/communication-react
package offers. - Azure Communication Chat SDK - To learn more about the chat web sdk.
- Teams Interop Meeting Chat Quickstart - To try out new beta features such as Rich Text Editor.
- FluentUI - Microsoft powered UI library
- React - Library for building user interfaces