ballerinax/microsoft.teams Ballerina library



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.


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


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.

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.

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);
} else {
  1. Use bal run command to compile and run the Ballerina program

You can find a list of samples here


import ballerinax/microsoft.teams;Copy


Released date: about 1 year ago

Version: 2.4.0

License: Apache-2.0


Platform: java11

Ballerina version: 2201.4.1

Pull count

Total: 1893

Current verison: 244

Weekly downloads

Source repository


Communication/Team Chat




Other versions

See more...