Use Natural Language With Betty, Your Digital Assistant In The Linux Terminal

Personal assistants like Siri and Google Now can be pretty useful, but there’s nothing like that for your Linux computer. Or at least, that used to be the case. There’s Sinus, a Siri-like utility for Mac users, but now it’s Linux’s turn with Betty.

What’s Betty?

Betty is a personal assistant similar to Siri and Google Now that can take commands that are written in plain English and execute them for you. There are loads of different commands it supports, which we’ll get into a bit later on. The only “downside” is that it’s limited to the terminal, and doesn’t take voice commands like Google Now and Siri do. Don’t let that scare you away though — it’s still extremely useful and easy to use.

Once Betty is installed, you can do all sorts of things with it. You can tell it to count how many words are in a file, change various configurations, find files, do Internet queries (and even download files), do file and directory operations such as change permissions and compress/uncompress, do various user commands, control music applications, and plenty more.

For each command that you give Betty, it will tell you which command it’s using to fulfill your request, as well as give you the output of said command. Not only does this make using the terminal a lot easier, but it can also be used as a teaching tool, so long as you pay attention to the commands it uses.

Around publication time of this article, Betty will only be about two months old. Therefore, it’s not capable of doing literally whatever you want just yet, but as you can see it already supports a large number of commands. The more time you give it, the more commands it will support. And waiting shouldn’t take long either — adding commands is pretty easy for the developers and there are already more than a handful of people that are contributing to the project.

What Betty Can Do

Here are some examples of Betty in action:

betty webqueries   Use Natural Language With Betty, Your Digital Assistant In The Linux Terminal

Here’s an example of some web queries that Betty can perform. In order for them to work, you’ll first need to run the command:

betty turn web mode on.

betty localstuff   Use Natural Language With Betty, Your Digital Assistant In The Linux Terminal

There are plenty of things you can do with Betty that relate to your computer. It can also make changes (like permissions, uncompress, deletion) and not just perform informational commands.

betty story   Use Natural Language With Betty, Your Digital Assistant In The Linux Terminal

I tried this one just because I felt like it, and it worked!

Installation of Betty

The hardest part about using Betty is really the installation. Sadly, there isn’t a simple PPA that you can add to install Betty and be finished.

betty install   Use Natural Language With Betty, Your Digital Assistant In The Linux Terminal
First, you’ll need to install its dependencies with the command:

sudo apt-get install ruby curl git

Since Betty is written in Ruby, installing the ruby package allows it to run. The curl package is needed whenever Betty wants to perform certain tasks related to the Internet, such as downloading a file. Finally, git is needed in just a moment in order to make downloading Betty easier. Then run:

cd && git clone https://github.com/pickhardt/betty

This will download the Betty code into a new folder in your Home folder. Lastly, run this command:

echo "alias betty=\"~/betty/main.rb\"" >> ~/.bashrc && source ~/.bashrc

This will insert something into your .bashrc file which allows you to simply type “betty” into the terminal and have the system know what to look for.

So again, it’s not the easiest way to install a program, but at least you won’t have to do more than just copy and paste some commands.

Share Your Thoughts On Betty

I’m excited to see how far Betty comes when it has plenty more commands than it currently supports. For the time being, you can check Betty’s Github page for the mostly complete (but non-exhaustive) list of supported Betty commands. Or, you can just play around with it and see what works!

How would you use Betty? What would you like to see it do that it can’t right now? Could Betty sway your non-geek friends to try Linux? Let us know in the comments!

12 Comments - Write a Comment

Reply

Vijit

Hey, can we get betty to work on cygwin. If yes, then how to set it up for cygwin

Reply

dragonmouth

“So again, it’s not the easiest way to install a program, but at least you won’t have to do more than just copy and paste some commands.”
It’s about time MUO started providing install procedures for distros other than UBUNTU and others that use PPAs. With the commands provided in this article users of ANY Debian-based distro can install the program.

Reply

techno

really neat. Since this is a ruby application I’m assuming it doesn’t call a 3rd party data center like Siri, Google Now and Cortana(most likely) do. I am definitely going to check this out. It’s pretty awesome. Seems like this is pretty close to being able to give speech back if you could use a speech recognition to output to betty and then use festival to output it back. Might be a really interesting thing to use as a front end for a home automation system. Also if you don’t like the name betty you could just alias it to something else, so win win all around. Nice share!

Reply

wickedgelfling

kk i tried what you listed/said…but my VM of ubuntu says fail…here is what i got from my terminal out puts maybe you can figgy what went wrong and how to fix it:

wickedgelfling@ubuntu:~$ sudo apt-get install ruby curl git
[sudo] password for wickedgelfling:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
git-man liberror-perl libreadline5 libruby1.8 ruby1.8
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-arch
git-cvs git-svn git-email git-gui gitk gitweb ri ruby-dev
ruby1.8-examples ri1.8
The following NEW packages will be installed:
curl git git-man liberror-perl libreadline5 libruby1.8 ruby
ruby1.8
0 upgraded, 8 newly installed, 0 to remove and 52 not upgraded.
Need to get 8,703 kB of archives.
After this operation, 22.6 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main libreadline5 i386 5.2-11 [123 kB]
Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.91.13 80]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/main liberror-perl all 0.17-1 [23.8 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise/main git-man all 1:1.7.9.5-1 [630 kB]
Err http://security.ubuntu.com/ubuntu/ precise-security/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.88.153 80]
Get:4 http://us.archive.ubuntu.com/ubuntu/ precise/main git i386 1:1.7.9.5-1 [5,963 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libruby1.8 i386 1.8.7.352-2ubuntu1.4 [1,787 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main ruby1.8 i386 1.8.7.352-2ubuntu1.4 [34.2 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ precise/main ruby all 4.8 [5,054 B]
Fetched 8,566 kB in 9s (902 kB/s)
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/curl_7.22.0-3ubuntu4.5_i386.deb 404 Not Found [IP: 91.189.88.153 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
wickedgelfling@ubuntu:~$ –fix-missing
–fix-missing: command not found
wickedgelfling@ubuntu:~$ cd && git clone https://github.com/pickhardt/betty
The program ‘git’ is currently not installed. You can install it by typing:
sudo apt-get install git
wickedgelfling@ubuntu:~$ sudo apt-get install gtt
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package gtt
wickedgelfling@ubuntu:~$ echo “alias betty=”~/betty/main.rb”” >> ~/.bashrc && source ~/.bashrc
wickedgelfling@ubuntu:~$ echo “alias betty=”~/betty/main.rb”” >> ~/.bashrc && source ~/.bashrc
wickedgelfling@ubuntu:~$ betty
bash: /home/wickedgelfling/betty/main.rb: No such file or directory
wickedgelfling@ubuntu:~$
wickedgelfling@ubuntu:~$ sudo apt-get install ruby curl git
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
git-man liberror-perl libreadline5 libruby1.8 ruby1.8
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-arch
git-cvs git-svn git-email git-gui gitk gitweb ri ruby-dev
ruby1.8-examples ri1.8
The following NEW packages will be installed:
curl git git-man liberror-perl libreadline5 libruby1.8 ruby
ruby1.8
0 upgraded, 8 newly installed, 0 to remove and 52 not upgraded.
Need to get 137 kB/8,703 kB of archives.
After this operation, 22.6 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com/ubuntu/ precise-security/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.91.15 80]
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/curl_7.22.0-3ubuntu4.5_i386.deb 404 Not Found [IP: 91.189.91.15 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
wickedgelfling@ubuntu:~$ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock – open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock – open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
wickedgelfling@ubuntu:~$ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock – open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock – open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
wickedgelfling@ubuntu:~$ clear

wickedgelfling@ubuntu:~$ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock – open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock – open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
wickedgelfling@ubuntu:~$ sudo apt-get install ruby curl git
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
git-man liberror-perl libreadline5 libruby1.8 ruby1.8
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-arch
git-cvs git-svn git-email git-gui gitk gitweb ri ruby-dev
ruby1.8-examples ri1.8
The following NEW packages will be installed:
curl git git-man liberror-perl libreadline5 libruby1.8 ruby
ruby1.8
0 upgraded, 8 newly installed, 0 to remove and 52 not upgraded.
Need to get 137 kB/8,703 kB of archives.
After this operation, 22.6 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.91.15 80]
Err http://security.ubuntu.com/ubuntu/ precise-security/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.92.201 80]
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/curl_7.22.0-3ubuntu4.5_i386.deb 404 Not Found [IP: 91.189.92.201 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
wickedgelfling@ubuntu:~$ clear

wickedgelfling@ubuntu:~$ sudo apt-get install ruby curl git
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
git-man liberror-perl libreadline5 libruby1.8 ruby1.8
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-arch
git-cvs git-svn git-email git-gui gitk gitweb ri ruby-dev
ruby1.8-examples ri1.8
The following NEW packages will be installed:
curl git git-man liberror-perl libreadline5 libruby1.8 ruby
ruby1.8
0 upgraded, 8 newly installed, 0 to remove and 52 not upgraded.
Need to get 137 kB/8,703 kB of archives.
After this operation, 22.6 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.91.13 80]
Err http://security.ubuntu.com/ubuntu/ precise-security/main curl i386 7.22.0-3ubuntu4.5
404 Not Found [IP: 91.189.91.13 80]
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/c/curl/curl_7.22.0-3ubuntu4.5_i386.deb 404 Not Found [IP: 91.189.91.13 80]
E: Unable to fetch some archives, maybe run apt-get update or try with –fix-missing?
wickedgelfling@ubuntu:~$ cd && git clone https://github.com/pickhardt/betty
The program ‘git’ is currently not installed. You can install it by typing:
sudo apt-get install git
wickedgelfling@ubuntu:~$ echo “alias betty=”~/betty/main.rb”” >> ~/.bashrc && source ~/.bashrc
wickedgelfling@ubuntu:~$

hopefully u can figgy what went wrong,,,this is a linux machine used in a VM prgram

Reply

Daniele Z

This is fan-freaking-tastic!
I’m gonna keep a close eye on Betty, this is actually gonna evolve real good.

Reply

shiruken

I followed the directions, but it’s spewing out all sorts of errors:

~$ betty what is the capital of florida?
Module /home/me/betty/lib/process.rb could not be loaded because of /home/me/betty/lib/process.rb:31: undefined (?…) sequence: /
(show|find|give|me|a|list|of|those|s)*
(?alls)?
(?mys)?
PROCESS(es)?
(with|which|that|s)*
(for|process|s)* (ids(?[0-9]+))?
(for|belonging|belong|to|by|s)* (users(?w+))?
((like|matching|with|pattern|containing|that|which|contain|s)+ (?w+))?
/
Module /home/me/betty/lib/translate.rb could not be loaded because of /home/me/betty/lib/translate.rb:13: odd number list for Hash
command: Command.browser(“https://tran…
^
/home/me/betty/lib/translate.rb:13: syntax error, unexpected ‘:’, expecting ‘}’
command: Command.browser(“https://tran…
^
/home/me/betty/lib/translate.rb:13: syntax error, unexpected ‘,’, expecting kEND
/home/me/betty/lib/translate.rb:15: syntax error, unexpected ‘}’, expecting kEND
/home/me/betty/lib/translate.rb:24: odd number list for Hash
category: “Translate”,
^
/home/me/betty/lib/translate.rb:24: syntax error, unexpected ‘:’, expecting ‘}’
category: “Translate”,
^
/home/me/betty/lib/translate.rb:24: syntax error, unexpected ‘,’, expecting kEND
/home/me/betty/lib/translate.rb:25: syntax error, unexpected ‘,’, expecting kEND
/home/me/betty/lib/translate.rb:27: syntax error, unexpected ‘}’, expecting kEND
/home/me/betty/lib/translate.rb:32: syntax error, unexpected $end, expecting kEND
Module /home/me/betty/lib/convert.rb could not be loaded because of /home/me/betty/lib/convert.rb:29: undefined (?…) sequence: /
(convert|save|transform)s
(?alls)?
(?mys)?
(?.*?)s
(to|as)s
(?.*)
/
Module /home/me/betty/lib/calc.rb could not be loaded because of /home/me/betty/lib/calc.rb:34: odd number list for Hash
command: “bc <<< #{arg1}#{op}#{arg2}",
^
/home/me/betty/lib/calc.rb:34: syntax error, unexpected ':', expecting '}'
command: "bc <<< #{arg1}#{op}#{arg2}",
^
/home/me/betty/lib/calc.rb:34: syntax error, unexpected ',', expecting kEND
/home/me/betty/lib/calc.rb:36: syntax error, unexpected '}', expecting kEND
/home/me/betty/lib/calc.rb:44: odd number list for Hash
category: "Calculate",
^
/home/me/betty/lib/calc.rb:44: syntax error, unexpected ':', expecting '}'
category: "Calculate",
^
/home/me/betty/lib/calc.rb:44: syntax error, unexpected ',', expecting kEND
/home/me/betty/lib/calc.rb:45: syntax error, unexpected ',', expecting kEND
/home/me/betty/lib/calc.rb:47: syntax error, unexpected '}', expecting kEND
/home/me/betty/lib/calc.rb:52: syntax error, unexpected $end, expecting kEND
Betty: I don't understand. Hopefully someone will make a pull request so that one day I will understand.

Reply

Eluwa M

Can we use it to run linux administrative commands ?

Reply

Chris

Just curious, but is there any way to rename it? Does it have to be Betty?

I’m not exactly a wiz at this but could you just do this:

echo “alias =”~/betty/main.rb”” >> ~/.bashrc && source ~/.bashrc

Reply

Chris

Ah, it changed my comment….well the gist of it was to change “alias betty” to “alias chosen-name”.

Reply

Joe

Somkebody needs to wrap this inside yad (much enhanced zenity fork) so it works in a gui.

If you already feel comfortable enough to use a terminal, you probably don’t need it.

It does sound like it has a lot of potential.

Reply

Ben L

I’ve been toying around, and testing the limits. Here’s what Betty really can (and can’t) do.

Reply

Ben L

ben@ben-ThinkPad-T420:~$ betty
Betty: What can I help you with?
ben@ben-ThinkPad-T420:~$ betty turn web mode on
Betty: Web queries ON
ben@ben-ThinkPad-T420:~$ betty whats the weather like
Asking the internet…
Couldn’t get a file descriptor referring to the console
Betty: Colorado Springs: It is currently sunny, 81 Fahrenheit
ben@ben-ThinkPad-T420:~$ betty how tall is the tallest dogwood tree
Asking the internet…
undefined method `[]’ for nil:NilClass
Betty: error querying web service undefined method `[]’ for nil:NilClass
ben@ben-ThinkPad-T420:~$ betty how tall is the tallest redwood tree
Asking the internet…
Betty: The Tallest Tree According to the researches of Dr A.C. Carder, the tallest tree ever measured was an Australian Eucalyptus regnans at Watts River, Victoria, Australia, reported in 1872 by forester William Ferguson. It was 132.6 m tall and almost certainly measured over 150 m originally. Another Eucalyptus at Mt Baw Baw, Victoria, Australia, is believed to have measured 143 m in 1885. The Dyerville Giant, a coast redwood, estimated to be 1,600 years old when it fell in March 1991, was proven to be 113.4 m high, not counting the 1.5 m of buried base. It grew in Humboldt Redwoods State Park, California, USA and was the tallest tree of modern times. (Answers.com)
ben@ben-ThinkPad-T420:~$ betty how long is 150 m in ft
Asking the internet…
undefined method `[]’ for nil:NilClass
Betty: error querying web service undefined method `[]’ for nil:NilClass
ben@ben-ThinkPad-T420:~$ betty how long is 150 m
Asking the internet…
undefined method `[]’ for nil:NilClass
Betty: error querying web service undefined method `[]’ for nil:NilClass
ben@ben-ThinkPad-T420:~$ betty what is 150 m in ft
492.13
ben@ben-ThinkPad-T420:~$ betty what is 150 m in feet
492.13
ben@ben-ThinkPad-T420:~$ betty how tall was the origonal empire state building
Asking the internet…
undefined method `[]’ for nil:NilClass
Betty: error querying web service undefined method `[]’ for nil:NilClass
ben@ben-ThinkPad-T420:~$ betty how tall is the origonal empire state building
Asking the internet…
undefined method `[]’ for nil:NilClass
Betty: error querying web service undefined method `[]’ for nil:NilClass
ben@ben-ThinkPad-T420:~$ betty how tall is the empire state building
Asking the internet…
Betty: The Empire State Building is 381 meters tall from the base to the roof; 373.2 meters from the base to the top floor; and 448.7 meters from the base to the antenna/spire. (Answers.com)
ben@ben-ThinkPad-T420:~$ betty what is 381 minus 373.2
Betty: Running bc <<< 381-373.2
sh: 1: Syntax error: redirection unexpected

ben@ben-ThinkPad-T420:~$ betty what is 381-373.2
Asking the internet…
Betty: 7.8
ben@ben-ThinkPad-T420:~$ betty where in the world is carmen sandiego
Asking the internet…
Betty: After she made her fortune in TV, she moved to LaJolla, an affluent nearby suburb. I hear she hangs aroud Black Beach[clothing optional] and frequents a near-by Chinese restaurant where a guy comes over and hand-makes lo mein noodles table-side. Cool,huh? She also enjoys a nice lunch at the Del Coronado Hotel in San Diego.an old, dignified,upscale hotel that keeps pesky autograph seekers away.I also heard{don't quote me] that she will be doing color-commentary for various event for th 2010 Olympics in Whistler, B.C. After all, because of her travels, she is multi-lingual. Keep watching!You never know where she might turn up next! Carmen Sandiego was in Ireland with her husband shamis o'grady. the couple have 2 kids and a castle which was funded by carmens earlier escapades. shamis is a half wolf lykin type monster which looks similar to Uncle Rukus's version of Cat'cha Freeman, but only on full moons. their two kids are very well known and go by the names of Ali G and Waldo kneterboccker. of the famous where is waldo franchise. but still be aware that waldo is from the west side and he will bust one in any of you east side members. you may ALSO remember ali g from his multi millian dollar catch frase BOYAKA SHA.Fun Facts:Carmen sandiego kissed chuck Norris and his beard ripped the skin off the left side of her face. that's why you havent seen it.Ali GWaldoshamis shown here holding the staff of kumlaskiashg.silent g. (Answers.com)
ben@ben-ThinkPad-T420:~$

Your comment