Commander for Microsoft Teams - Your Custom Bot that runs on your Command!

Sep 22, 2020 | Commander

copied

Microsoft Teams is a great tool for communicating with your co-workers or friends. But maybe you have some functionality you’d like to create or install into your Team’s space? Nimbella Commander is your bot that allows you to not only install pre-built commands into your Microsoft Teams workspace, but you can also build custom commands or customize pre-built commands.

In this article, we will:

  1. Install pre-built commands with ZERO programming knowledge.
  2. Create and edit your custom commands in JavaScript.
  3. Apply secrets to your commands, keep your API keys a secret!

How to Install pre-built commands with ZERO programming knowledge?

What’s great about Nimbella Commander is that there are several pre-built commands you can install and get started. We got utility commands for all users, commands for DevOps and developers, and commands for business folks. So regardless if you’re working in tech, finance, education, healthcare, or just want a command that is interesting or fun, there’s something for you! We keep all of our open-source command sets in our GitHub repository.

Here’s a list of all the pre-built commands that we have:

Utilities:

corona_stats - Live stats for the pandemic, worldwide, or in a specific country.

times - Displays the current time in AM/PM format for the given cities.

translate - Translates text to a given language.

weather - Get weather conditions for a city.

DevOps:

aws - Interact with AWS. Display your bill and run commands for EC2, Dynamodb, RDS, and Route53.

dig - lookup DNS.

do - Interact with you DigitalOcean drops. You can fetch your DO usage, list IP addresses, list droplets, power them on and off, reboot them, take a snapshot of them, and see the status.

github - Interface with GitHub. There are 10 commands where you can interact with issues, pull requests, and other aspects of your repositories.

gitlab - Interface with GitLab. You can view contribution stats, create a ticket, assign issues, and list users in a repo.

ibm - Interact with IBM Cloud & IBM Watson services, such as Cloud Functions, Visual Recognition, Language Translator, and the Tone Analyzer.

jira - Interact with Jira by creating, assigning, and transitioning issues.

Circleci - Interact with CircleCI.

BizOps:

awsbill - Fetch AWS billing information. You can display your current bill or select a specific month/year.

dobill - Fetch DigitalOcean billing information.

shopify - Interface with Shopify by adding notes to orders, displaying orders & inventory, and display the number of products sold.

If you type registry , it will show the list of available command sets, clicking one will give out the details and an installation button. For example, the “translate” command is a fun way of taking text and translating it into whatever language you want inside of Teams. This allows you to communicate with other members of the channel in their own language.

Nimbella Command sets

Or you can also install using csm install command 

Nimbella Command sets

If you want to say “How are you” in French, you can just type run translate french "hello" , and it told me how to say that in French.

nimbella-command-sets-microsoft-teams

To view the list of command sets that are installed within your team’s workspace, type csm list.

microsoft teams command set

How to Create and Edit your custom commands?

So maybe you have some functionality you want to build, but you don’t want to deal with learning about server logic or setting up the infrastructure to host your app. Here is an easy way to build and edit code so that you can start building your custom commands.

After selecting Commander, type command create helloWorld . This will create a command called helloWorld that can be edited. The name does not have to be helloWorld. Running command create anyNameHere  will create the same template that can be edited.

microsoft teams command set

To run this helloWorld command, you can click on the run helloWorld button from the response. Alternatively, you can type run helloWorld  to execute this command.

microsoft teams command set

The template this generates displays some basic text. So now you can see how simple it is to display text from a command in your Teams workspace.

When creating a command, multiple parameters can be specified - required <> or optional [<>]:

command create anyNameHere <parameter1> [<parameter2>] 

Now that you’ve created a custom command, you can now edit it!

Click the “edit the code” link that was generated when you created the command to get redirected to where you can edit the code.

microsoft teams command set

This code is very straightforward. You have a return type that’s selected as “in_channel”, which means it will display in the channel. You also have a value called “text” which displays the text.

To test what it is like to edit the code:

  • Go to text: “This is a default response for a newly created command with text: “ + commandText 
  • Change it to text: “I just changed this text” 
  • Click the save button at the top right corner.
  • Go back to Teams and run the command again.

The response will now say “I just changed this text”. And just like that, you’ve edited your first command! From here, you can start thinking about new functionality you can build and start building on top of this template!

To learn more about creating commands, check out the reference guide from Nimbella Commander to see all the commands that can be run on Microsoft Teams.

How to Apply Secrets to your Commands on Microsoft Teams?

Lots of services are accessible only through APIs but imagine how horrible it would be if your API keys got out? It’s important to make sure that your API keys, credentials, and anything you don’t want public is kept outside of Teams. Commander natively provides an option to store and securely share secret keys within the commands. The Secret Creator is what you’ll use to encrypt these values outside of Teams.

To start creating secrets, type secret create 

microsoft teams secret command

Click the link that says “Secret Creator” to be redirected to where you can start encrypting values. Once you create a secret, the UI will prompt you to copy a command.

Example command: secret add <secretName> <encrypted_value> 

Copy that command by clicking the “Clipboard Copy” button and run the command inside of Teams.

microsoft-teams-secret-key

The response for the secret add command will show the encrypted value of your secret to keep it secure.

In this example, we have created a secret with the name of myApiToken. We can use this to play around with secrets.

microsoft teams secret API

Now, to use this secret within your command, you would need to edit the command code. Type command code helloWorld  to get the edit code link. Click on “edit the code” to be redirected to your code.

Here we will access the myApiToken secret by using the code below:

let myToken = secrets.myApiToken; 

Add + myToken  to the end of the text:  field.

The parameter “secrets” is what is storing all the secrets you generated and applied to your workspace.

microsoft teams secret key

Type run helloWorld  to execute the command.

microsoft-teams-secret-privacy

Now you’re ready to start building amazing and powerful commands inside your Microsoft Teams workspace. You have your custom robot that you can teach to do anything and run anything. At this point, the only limitation is your creativity! To learn more about building commands in Microsoft Teams, check out the documentation to learn more from Nimbella.

Recent Posts