Camly - A Responsive Blogger Theme, Lets Take your blog to the next level.

This is an example of a Optin Form, you could edit this to put information about yourself.


This is an example of a Optin Form, you could edit this to put information about yourself or your site so readers know where you are coming from. Find out more...


Following are the some of the Advantages of Opt-in Form :-

  • Easy to Setup and use.
  • It Can Generate more email subscribers.
  • It’s beautiful on every screen size (try resizing your browser!)
by

Abot - An Open Source Tool to make your own Digital Assistant!



Hey folks. I had given an article to Open Source for You to publish. And this is the article about a open source tool which helps to make your own digital assistant. Cool, isn't it?


Everyone has always wished to create his/her own digital assistant that talks back and completes everyday tasks. Right? Now it’s easier with this open source tool Abot that’s written in Go programming language.

Introduction to digital assistant:
Basically, A digital assistant (also called virtual assistant) is an application program that can understand human language and complete electronic tasks for the user. Such tasks include taking dictation, reading text or email messages aloud, looking up phone numbers, anticipating requests, placing calls and reminding the user about appointments.  

Today’s digital assistants like Apple’s Siri, Google Now and Cortana, are programmed with artificial intelligence, voice recognition and machine learning technologies. As the user interacts with his/her digital assistant, the Artificial Intelligence programming uses sophisticated algorithms to learn from data input and become better at predicting the user's needs. Tomorrow's digital assistants will be built with more advanced cognitive computing technologies which will allow a digital assistant to understand and carry out multi step requests and perform more complex tasks.

You must be knowing that digital assistants are enormous software and very complex. Abot solves this problem by making it easier with pre-installed tools that manage and understand human language.

Introduction to Go- Programming language:go.png

As wikipedia says, Go is an open-source programming language created at Google by Robert Griesemer, Rob Pike and Ken Thompson. Though the development of Go programming language started in 2007 and it was publicly released in November 2009.

Go is basically, a general purpose programming language with advanced features and a clean syntax ( ‘C’ like syntax with no semicolons). Because of its wide availability on a variety of platforms, its well-documented library, and its focus on good software engineering principles, Go is an ideal language to learn. Go is different. Go is not what you think it is. It is not Java or Ruby. It is not trying to be a language theorist’s dream. Go is not about type hierarchies. It is not about object-oriented programming or functional programming.

The process we use to write software using Go is straightforward:
  • Gather requirements
  • Find a solution
  • Write source code to implement the solution
  • Compile the source code into an executable
  • Run and test the program to make sure it works
This process is iterative and the steps usually overlap.

What is Abot?
Abot is a digital assistant framework written in Go programming language, Abot’s framework is designed to help one in building in his/her own assistant and customizing it according to their needs. whether that's a computer that answers phones and intelligently routes calls, schedules your business travel, or is just a better take on Siri that orders Ubers and does your laundry.

Abot exposes a simple HTTP API, so you can easily connect it to send, process, and respond to texts, emails, and more.

How the framework of Abot tool works?
The brain of Abot’s tool mainly consists of three parts :

  • An API(application program interface) that accepts natural language (human language) input.
  • A state machine for tracking grammar and context across inputs to enable chaining of commands.
  • A router to select the correct plugin that sends input based on the present commands and past context.

Abot tool combines these three parts and libraries to fasten the process of coding one’s personal digital assistant.

For every message Abot receives, Abot processes, routes, and responds to the message. Actually deciding what to say is the role of plugins. Let's take a look at an example:

  1. User sends a message via the console, SMS, email, etc.: Show me Chinese restaurants nearby.
  2. Abot pre-processes the message, breaking the message into key components:
    1. Commands: [Show]
    2. Objects: [me, Chinese restaurants nearby]
  3. Abot routes this message to the respective plugin:
  1. Route: [find_chinese]
  2. Plugin: [restaurant]
  1. The plugin, then, generates a response : Sure, how does Sun Shi sounds? It's nearby.
  2. Abot sends the response to the user.

Abot sends the response through the same channel the user chose, so if the user sends Abot a text, Abot will respond in text automatically. Thus, every message goes from User --> Abot --> Plugin --> Abot --> User.

How to build your own personal assistant?
As mentioned earlier, Abot is a digital assistant framework that is based on Go programming language. Abot requires some prerequisites like Go (version >= 1.6) and PostgreSQL (version >= 9.5). Once you have ensured that you have these dependencies, we can move forward to running Abot server on your terminal.
  1. Fetching Abot using go get :


go get github.com/itsabot/abot
cd $GOPATH/src/github.com/itsabot/abot
go get github.com/robfig/glock

     2.  Setting Glock binary path:

export PATH=$PATH:/home/ubuntu/workspace/bin/

  3. Running the setup script, passing in your Postgres       credentials/host if needed.

cd $GOPATH/src/github.com/itsabot/abot
cmd/setup.sh [username[:password]@host[:port]]

If you don’t pass anything to the script, the Postgres will defaultly set to host = 127.0.0.1, port = 5432 and username = postgres.

   4. Once the script has completed, run

$ abot server

And then visit Abot at localhost:4200.

Once we have everything installed and running, we can start communicating to Abot. For communicating with Abot locally, we can use the command $ abot console. But before that, we’ll need to sign up. To do that go to http://localhost:4200 and click Sign up in the header. Fill in appropriate information, and remember the phone number you use (which should be in the format of +918889992221 -- no spaces with a leading +91).

Once you’ve created an account, type

$ abot console +918889992221
> Hi
Hi there. :)

Replace the number with the number you used to sign up. Abot won’t do much at this point, we will need to add plugins to add more functionalities.

Installing Plugins :

When Abot boots, it starts every plugin listed in your plugins.json file.
Open up plugins.json in your text editor of choice, and add to the Dependencies, so it looks like:

{
   "Dependencies": {
       "github.com/itsabot/plugin_onboard": "*",
       "github.com/itsabot/plugin_weather": "*"
   }
}

Then in your terminal run:

$ abot plugin install
Fetching 2 plugins...
Fetching dependencies...
Installing plugins...
Success!
$ abot server

And from another terminal:

$ abot c +918889992221
> What's the weather like in Mumbai?
It's 74 and sunny in Mumbai.

 
Creating your first Abot plugin :

Abot provides all the tools you need to quickly and easily write these plugins through its shared library. To write your own plugin, you should know about Go programming language.

Let's take a look at a "Hello World" plugin, which will introduce you to the plugin API. Let's download the plugin by adding it to our plugins.json and installing it like so:

$ tail $GOPATH/src/github.com/itsabot/abot/plugins.json
{
   ...
   "Dependencies": {
       "github.com/itsabot/plugin_onboard": "*",
       "github.com/itsabot/plugin_hello": "*"
   }
}

$ abot plugin install
Fetching 2 plugins...
Installing plugins...
Success!

Now let's take a look at the contents of the plugin. Pay close attention to the inline comments, which explain each piece of the plugin API as its introduced.

// Package hello responds to "Say something" with "Hello World".
package hello

import (
   "log"

   "github.com/itsabot/abot/shared/datatypes"
   "github.com/itsabot/abot/shared/nlp"
   "github.com/itsabot/abot/shared/plugin"
)

var p *dt.Plugin
var sm *dt.StateMachine

func init() {
   // When Abot receives a message, it'll route the message to the correct
   // package. Doing that requires a trigger, which tells Abot to send the
   // response to this package when Commands include "say" and Objects
   // include "something", "hello", etc. Case should always be lowercase,
   // and the words will be stemmed automatically, so there's no need to
   // include variations like "cat" and "cats".
   trigger := &nlp.StructuredInput{
       Commands: []string{"say"},
       Objects:  []string{"something", "hello", "hi"},
   }

   // Tell Abot how we'll respond to first messages and follow up messages
   // from a user in a conversation.
   fns := &dt.PluginFns{Run: Run, FollowUp: FollowUp}

   // Create the package, setting it up to communicate with Abot through
   // the functions we specified.
   var err error
   p, err = plugin.New("github.com/itsabot/plugin_hello", trigger, fns)
   if err != nil {
       log.Fatalln("building", err)
   }

   // Abot includes a state machine designed to have conversations. This
   // is the simplest possible example, but we'll cover more advanced
   // cases with branching conversations, conditional next states, memory,
   // jumps and more in other guides.
   //
   // For more information on state machines in general, see:
   // https://en.wikipedia.org/wiki/Finite-state_machine
   sm = dt.NewStateMachine(p)
   sm.SetStates(
       []dt.State{
           {
               OnEntry: func(in *dt.Msg) string {
                   return "Hello world!"
               },
               OnInput: func(in *dt.Msg) {
               },
               Complete: func(in *dt.Msg) (bool, string) {
                   return true, ""
               },
           },
       },
   )
}

// Run is called when the user first enters the package in a conversation. Here
// we simply reset the state of the state machine and pass it on to FollowUp().
func Run(in *dt.Msg) (string, error) {
   sm.Reset(in)
   return FollowUp(in, resp)
}

// FollowUp is called as the user continues to message the package after the
// user's first message. Here we tell the state machine to move to the next
// available state and return the response from that move--since there's only
// one state, it will always be "Hello world!" from the OnEntry function.
func FollowUp(in *dt.Msg) (string, error) {
   return sm.Next(in), nil
}

You can find and edit this file at $GOPATH/src/github.com/itsabot/plugin_hello. You should see Abot boot with a line or two mentioning our new plugin, Hello World. Open another terminal while abot server is still running, and type (using the same phone number with which you used to sign up at http://localhost:4200):

$ abot console +918889992221
> Say hi
Hello World!

Abot just routed your message to the plugin based on the trigger defined in our abot_hello.go. The state machine told it to respond with "Hello World!" when it entered its first state, and since there were no other states, that state is replayed every time a new message matching our trigger is sent to Abot.

Deploying your Abot:

To make Abot available to the outside world, we'll have deploy it to a server.We will be using Heroku for now. Go and Abot do make it easy to deploy on any web server, though. Open a terminal and run:

$ echo 'web: abot server' > Procfile
$ heroku create --buildpack https://github.com/itsabot/heroku-buildpack-go
$ heroku addons:create heroku-postgresql:hobby-dev --version 9.5
$ cat db/migrations/up/*.sql | heroku pg:psql
$ cat data/cities.csv | heroku pg:psql -c "COPY cities(name, countrycode) FROM stdin DELIMITER ',' CSV;"
$ heroku config:add ABOT_ENV=production \
ABOT_URL="https://YOURURL" \
ABOT_SECRET=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-64};echo;)
$ git push heroku master
$ heroku open

Be sure to replace YOURURL above with a user-presentable URL. If everything booted correctly, you'll see the "Congratulations, you're running Abot!" screen. If not, you can track down any issues with heroku logs --tail.

Once you see the Congratulations screen, let's try communicating with our Abot. Sign up for an account using the web interface, then:

$ abot console https://yourapp.herokuapp.com +yourphone
> Hi
Hello there!

Replace yourapp and yourphone with the appropriate values, and you should see Abot respond to your message!

Abot is currently a new organization and new versions will be released soon. One can also contribute to the project.

References:


















0 comments:

Post a Comment