Announcing Microsoft Bot Framework SDK for Go

Announcing Microsoft Bot Framework SDK for Go

Sahil Lakhwani
Sahil Lakhwani

Consequent to great feedback to BotKube, an application for messengers like Slack and Mattermost to monitor and debug Kubernetes deployments, we have got interests from Microsoft Teams users for an integration with BotKube. An integration, which would help them monitor their Kubernetes cluster from a Teams client. Since BotKube is architecturally designed to work independently of a messaging platform, it seemed a viable thing to integrate it with Teams.

Microsoft Teams uses the Microsoft Bot Framework to allow users to write bot applications. The Bot Framework is a set of tools, SDKs, templates and services to build conversational bot applications. The official SDKs are available for Python, C#.NET, Java and Javascript. Since BotKube is built in Go, there was a need of an interface to the Bot Framework services in Go, for a seamless integration of BotKube to Teams. This encouraged us to write a Go SDK that wraps the services of the Bot Framework.

Today, we are excited to announce the first release of the Bot Framework SDK for Go; an SDK written in Go that enables users to build bot applications over the Bot Framework in Golang. The SDK enables application developers to build conversational bots for Microsoft Teams.

A bot application built using this SDK can send text, interactive cards and attachments in a conversation with a user. Apart from a receive-reply conversation, developers can build bot applications to push messages in a conversation to Teams client.

Microsoft team bot framework SDK

The SDK’s architecture is inspired by the official SDKs and thus follows all the guidelines of the Bot Framework. It takes care of the authentication for conversation requests between a bot application and a Teams client, as per the guidelines. All the requests to and responses from the Bot Framework service adhere to the API definitions as specified. The SDK provides users the flexibility to create messages sent to the Teams client. The code for the Bot Framework SDK is publicly available on GitHub.

The GitHub repository of the SDK includes an example bot, glimpsed below. The bot just echoes whatever is sent by the user.

Echobot

The below snippet from the example shows how a handler, which is a way to command the SDK on an event trigger, is created. And then a call to an SDK function is made to send a reply. The complete explanation for echo bot sample.

var customHandler = activity.HandlerFuncs{
    OnMessageFunc: func(turn *activity.TurnContext) (schema.Activity, error) {
        activity := turn.Activity
        activity.Text = "Echo: " + activity.Text
        return turn.TextMessage(activity), nil
    },
}

err := adapter.ProcessActivity(ctx, activity, customHandler)

While the above snippet sends text, an attachment can be sent by modifying the activity:

var customHandler = activity.HandlerFuncs{
  OnMessageFunc: func(turn *activity.TurnContext) (schema.Activity, error) {
  activity := turn.Activity
  activity.Text = "Echo: " + activity.Text
  activity.Attachments = &schema.Attachment{
     ContentURL: "https://statics.teams.microsoft.com/evergreen-assets/skype/v2/smile/50.png",
  }
  return turn.TextMessage(activity), nil
 },
}

Integrating BotKube with Microsoft Teams

The SDK is being used to make BotKube interact with Teams. After the integration, users will be able to work with their Kubernetes clusters using a Teams client. The client can monitor, debug and run checks on Kubernetes cluster(s). The user interaction will be quite similar to how BotKube offers for Slack or Mattermost today.

Further work

The SDK is being enhanced for performance and new features are being added which are supported by the Bot Framework. The required work is tracked on the GitHub repository’s issues page. It’ll be our pleasure to welcome any contribution to the SDK.

Hope this blog post on bot framework SDK for Go was helpful to you. You can follow us on Twitter and LinkedIn for regular updates.

Infracloud logo
Build Better Cloud Native Products, Faster!
Learn More

Posts You Might Like

This website uses cookies to offer you a better browsing experience