Azure Communication Service Communication Chat client library sample for JavaScript

These sample programs show how to use the TypeScript client libraries for Azure Communication Service Communication Chat to create chat threads and send messages.

File Name Description
threadOperations.js create, retrieve, update and delete a chat thread
messageOperations.js send, list, update and delete chat messages
participantsOperations.js add, list, and remove participants from a chat thread

Prerequisites

The sample is compatible with Node.js >= 8.0.0.

You need an Azure subscription and an Azure Communication Service Instance to run these sample program.

Adapting the samples to run in the browser may require some additional consideration. For details, please see the package README.

Setup

To run the sample using the published version of the package:

  1. Install the dependencies using npm:
npm install
  1. Edit the file sample.env, adding the correct credentials to access the Azure service and run the samples. Then rename the file from sample.env to just .env. The sample programs will read this file automatically.

  2. Run whichever samples you like:

node threadOperations.js

Alternatively, run a single sample with the correct environment variables set (step 3 is not required if you do this), for example (cross-platform):

npx cross-env COMMUNICATION_CONNECTION_STRING="<connection string>" node threadOperations.js

Next Steps

Take a look at our API Documentation for more information about the APIs that are available in the clients.