All Projects → owainlewis → X2

owainlewis / X2

An in browser (AI) artificial agent that can automate tasks and perform actions based on voice input

Programming Languages

go
31211 projects - #10 most used programming language

X2

An in browser AI that can understand your voice and perform actions based on your commands.

https://x2ai.herokuapp.com/

A customisable, voice activated intelligent agent for automating tasks.

X2 can perform complex actions and store information for you. X2 comes with a voice activated web interface, a simple memory (which can be expanded) and a basic notion of self identity.

You can deploy X2 on any Linux server. You might want to use it to automate tasks. For example:

You: Deploy the user service to producton X2: Ok. Deploying the user service to production now.

Deploying your X2 agent to Heroku

heroku create
git push heroku master

Creating custom modules

X2 is designed for customisation. A module has two methods Matches and Perform. The first checks if an input phrase sent to X2 matches and the second performs some action returning a reply that gets sent back to the caller.

Let's take a look at a very simple module which simply returns the current time when asked things like "What is the time?" or "What time is it?"

All modules should live in modules/name-of-module

package time

import (
	"github.com/owainlewis/x2/agent"
	"regexp"
	"time"
)

type Time struct {
}

func (t Time) Matches(input string) bool {
	var expr = regexp.MustCompile(`time`)
	return expr.MatchString(input)
}

func (t Time) Perform(agent *agent.Agent) agent.AgentReply {
	current_time := time.Now().UTC()
	return agent.Reply("The Current time is " + current_time.Format("2006-01-02 MST"))
}

After creating a module you need to add add it to your agent

emily := agent.New()
emily.SetActions(modules.Ping{}, modules.Time{}, modules.Weather{})
emily.Query("What is the weather like in San Francisco?")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].