The command line as a bot?

Luca Hammer
breakingbotnews
Published in
8 min readAug 30, 2016

--

In the beginning there were knobs, then came the punched cards and finally the command line which is still used today to interact with computers. Even though the majority switched to graphical user interfaces.

When we started to talk about bots I immediately thought about command lines. There are many similarities between them. Both are primarily text based tools. They are interactive. You enter something and get something back. I want to explore this comparisons further to get a better understanding of what a bot is and can be.

In the first part of the article I focus on what the user can see and how they can interact. The interface. It is probably the most important part of the user experience. In the second part I look at behavior and functionality of the different tools before I try to come to a conclusion and what are the biggest differences between bots and command line (tools).

The interface

Command lines use a command line interface. The command line interface (CLI) is a text based interface where a user can input text. It can be compared to the messenger interfaces, where a user can input text as well. Today most command line interfaces live in windows on a graphical user interface (GUI) but you can set up a computer to run without a GUI and only use the command line interface.

Facebook Messenger Overlay (Screenshot from 10.08.2016)

As examples I used the overlay messenger window of the Facebook messenger which can be used while browsing facebook. There are dedicated interfaces as well. Messenger.com, the Facebook messenger app and other tools that use Facebook messenger API. For this article I will refer to the interface on facebook.com and messenger.com if not stated otherwise. There are two on facebook.com, the overlay, seen in the screenshot, and the messenger view. But all three, overlay, dedicated and messenger.com work in the same way and look similar enough to not further distinguish between them.

At the bottom there is a dedicated area where users can input text. There are buttons which enable the user to attach different things. Photos, stickers, gifs, emojis and attachements. There is a a button to send an emoji that can be defined on a per chat basis. The default one is the Facebook Like Emoji (Thumb up). The text area tells the user to “Type a message…”. Above the input area there is the text area which shows the chat messages from all parties. At the top of the messenger interface there is the name of the chat, per default the name of the other party, a button with options and a button to close the overlay. This top area looks different in the dedicated messenger area on facebook.com and messenger.com, but only because they are differently arranged.

In the screenshot from messenger.com you see that the information about the chat is on the right side. The input area is at the bottom, the message area in the middle and there is a list of recent chats on the left side.

Messenger.com conversation with swell.wtf bot (Screenshot 10.08.2016)

I wrote above that there is a dedicated text input area. But in the screenshot you see that there are buttons in the message area as well. This is a recent feature which enables users to interact outside the text input area. There are different of such rich interaction areas.

Today most chat interfaces support more media types than text but text is still the most important one.

Messages from other parties are displayed on the left, your own messages appear on the right side of the message area. There are little symbols that indicate that a message was read by the other party.

Windows PowerShell (Screenshot 10.08.2016)

The next example is the Windows Power Shell. It is one of the default command line interfaces of Windows. On Linux Distributions and OSX you can find the Terminal and various other interfaces which all work in a similar fashion.

At first the Power Shell looks nothing like the Facebook Messenger interface. But this will change as we take a closer look.

We don’t see a dedicated input area, but it is still there. You can’t click wherever you want in the Power Shell and input text like you may be used to from a text editor. The only place to enter text is after PS C:\Users\Luca>. When you press enter, you get a new line where you can enter the next command. Similar to how messages in the Facebook Messenger are displayed with the oldest first, the oldest command is displayed first. But you don’t get the neat left right view. Everything floats to the left. Everything? Even though command line interfaces only support text, they can display complex information.

htop in tmux via SSH in Putty (Screenshot 10.08.2016)

In the Screenshot you see the output of a tool called htop, which displays different information in realtime (view is updated every x ms) about the system it runs on. As you can see the text input area vanished. But you can still use keys, though they are immediately sent without pressing enter. Most of them change the view, some can stop programs or activate other features of htop. The interesting similarity is that you can click with the mouse pointer as well. For example to sort the shown programs by a certain column.

While the Facebook messenger interface supports rich media types and certain interactive elements, command line interfaces offer a much richer interface because programmers aren’t limited to certain structures.

Command line interfaces and messengers are both primarily text based but both offer limited rich interfaces which can display information differently and give additional interactive options.

While bots can run in many more environments than only the Facebook messenger the most popular platforms at the moment have similar features.

Behaviour of Bots and CLI tools

There are many different kinds of bots and many different kinds of command line interface tools.

Let’s start with the CLI. It has built-in commands, can be extended with custom commands, there are interactive shells that run inside a CLI and there are CLI programs as well as interactive CLI programs.

I propose to compare bots to interactive shells and CLI tools. Other CLI programs can be run interactively as well in the sense that you can start them again and again. Built-in and added commands are part of the CLI similar to the attachment options of a messenger.

Interactive Python shell, interactive help() (gif 10.08.2016)

When using a CLI, I have to start the interaction with the name of the program I want to use (if I don’t use the built in / added commands). In the example above I started the interactive Python shell with the command “python”. The Python shell starts and shows me the version and some other information. Inside the program I can use the commands provided by that program. In the example I start the interactive help with the command “help()”. I then get greeted: “Welcome to Python 2.7!” and provided with some information about how to use the help. I then use the examples topics to get a list of available help topics. After that I mistype “modules” as “moduls”. The interactive help then tells me that it didn’t find documentation for it. After that I correctly type “modules” and get an intermediate message: “Please wait a moment while I gather a list of all available modules…”, before the list is displayed.

I find that behaviour interesting. On one hand the welcome message, which gives me a sense of personality. Again with the waiting message, where the program even refers to itself as “I” like it is self-conscious. It takes some seconds until all modules names are collected, so it makes sense to let the user know. But the programmers didn’t choose a generic message, but let the program speak from its own perspective.

Mica, the Hipster Cat Bot via Facebook Messenger(gif 10.08.2016)

In the Gif above I recorded my conversation with Mica, the Hipster Cat Bot. Because the Facebook Messenger has a GUI, I didn’t write that I want to chat with Mica, but searched for it in my contacts and tapped on it to start the chat. Once again I ask for “help” and as a reply I get a list of available commands. Mica, like many modern chatbots, was given fuller personality. It has a name and even an attitude (Hipster). Instead of a dry “Available commands:”, she (or is Mica male?) writes “ Meow! I understand the following:”. Again the program suggests that it isn’t just a program but that something I can hold a conversation with.

Only few command line tools try to have something like a personality and act like humans, while this is the norm for conversational bots. But many CLI tools have some parts that hint at a personality. Often as jokes and easter eggs.

Biggest difference: NLP, continuity and environment

There are many similarities between bots and CLI tools in how they work and act. Many bots could be implemented as CLI tools. The only difference would be that they get input and give output to the command line interface instead of a messenger API. And many CLI tools could be implemented as bots. Which would probably be less useful because they often do change things on the system they are running on.

Conversational bots often make use of Natural Language Processing (NLP) to give the conversation between user and bot a natural feeling. Users can then use sentences (mostly questions) like they would in other conversations and the program tries to filter the relevant parts to give a reply which can be again translated into a natural sounding sentence. As far as I know this isn’t used by any CLI tools at the moment, but could be in the future. Because of what CLI tools mostly do it may not be ideal to have the vagueness that natural language introduces. “Delete all unnecessary files!”.

CLI tools don’t have a memory in most cases. Some save settings. Bots on the other hand try to learn to know the user to have better conversations. They ask users about their preferences and act accordingly. This gives a sense of continuity.

People are used to chat with other people in messengers. Now bots appear in the same environment. CLI tools on the other hand live in command line interfaces where people interact with machines in most cases.

In this article I showed how similar CLI tools and bots are. They are both text based interfaces which can be extended with a more graphical interface and behavior. The basic interaction of writing text back and forth works the same. The big differences stem from what they can do, how people use them and in what environment they exist.

--

--

Grew up in the Alps. Father. Working with data and words. Please 👏 and share the article if you enjoyed it.