ballerinax/microsoft.teams Ballerina library

2.4.0

Overview

Ballerina connector for Microsoft Teams is connecting to MS Teams platform API in Microsoft Graph via Ballerina language. It provides capability to perform basic functionalities provided in MS Teams such as Sending messages, Viewing messages, Creating Teams, Channels and Chats, deleting and updating resources etc programmatically.

This module supports Microsoft Graph API v1.0.

Prerequisites

Before using this connector in your Ballerina application, complete the following:

  • Create a Microsoft 365 Work and School account

  • Create an Azure account to register an application in the Azure portal

  • Obtain tokens

    • Use this guide to register an application with the Microsoft identity platform
    • The necessary scopes for this connector are shown below.
    Permissions nameTypeDescription
    Channel.CreateDelegatedCreate channels
    Channel.Delete.AllDelegatedDelete channels
    Channel.ReadBasic.AllDelegatedRead the names and descriptions of channels
    ChannelMember.Read.AllDelegatedRead the members of channels
    ChannelMember.ReadWrite.AllDelegatedAdd and remove members from channels
    ChannelMessage.SendDelegatedSend channel messages
    ChannelSettings.ReadWrite.AllDelegatedRead and write the names, descriptions, and settings of channels
    Chat.CreateDelegatedCreate chats
    Chat.ReadWriteDelegatedRead and write user chat messages
    ChatMember.ReadWriteDelegatedAdd and remove members from chats
    ChatMessage.SendDelegatedSend user chat messages
    Group.ReadWrite.AllDelegatedRead and write all groups
    Team.CreateDelegatedCreate teams
    Team.ReadBasic.AllDelegatedRead the names and descriptions of teams
    TeamMember.ReadWrite.AllDelegatedAdd and remove members from teams
    TeamSettings.ReadWrite.AllDelegatedRead and change teams' settings

Quickstart

To use the MS Teams connector in your Ballerina application, update the .bal file as follows:

Step 1 - Import connector

Import the ballerinax/microsoft.teams module into the Ballerina project.

Copy
import ballerinax/microsoft.teams;

Step 2 - Create a new connector instance

You can now make the connection configuration using the OAuth2 refresh token grant config.

Copy
teams:ConnectionConfig configuration = {
    auth: {
        refreshUrl: <REFRESH_URL>,
        refreshToken : <REFRESH_TOKEN>,
        clientId : <CLIENT_ID>,
        clientSecret : <CLIENT_SECRET>
    }
};

teams:Client teamsClient = check new (configuration);

Step 3 - Invoke connector operation

  1. Create a team
teams:Team info = {
    displayName: "<TEAM_NAME>",
    description: "<TEAM_DESCRIPTION>"
};

string|error newTeamId = teamsClient->createTeam(info);
if (newTeamId is string) {
    log:printInfo("Team succesfully created " + newTeamId);
    log:printInfo("Success!");
} else {
    log:printError(newTeamId.message());
}
  1. Use bal run command to compile and run the Ballerina program

You can find a list of samples here

Import

import ballerinax/microsoft.teams;Copy

Metadata

Released date: over 1 year ago

Version: 2.4.0

License: Apache-2.0


Compatibility

Platform: java11

Ballerina version: 2201.4.1


Pull count

Total: 1896

Current verison: 244


Weekly downloads


Source repository


Keywords

Communication/Team Chat

Cost/Paid

Vendor/Microsoft


Contributors

Other versions

See more...