Skip to content
background-image background-image

Using Azure Bot Service

This example shows how to use Azure Bot Service module.

Most APIs require authorization provided by @azure/identity module which is imported as azure.identity

Authorization using DefaultAzureCredential class is not supported, you can use ClientSecretCredential

@azure/arm-botservice module is imported as azure.botService

List bots

const { ClientSecretCredential } = azure.identity;
const { AzureBotService } = azure.botService;

const account = "<account>";
const subscriptionId = "<subscription ID>";
const clientSecretCredential = new ClientSecretCredential(
  "<tentant-id>",
  "<client-id>",
  "<client-secret>"
);

const client = new AzureBotService(clientSecretCredential,subscriptionId);

const resArray = new Array();
for await (let item of client.bots.list()) {
  resArray.push(item);
}

See Azure Bot client library for JavaScript for full examples.