Microservice Recipe: Virtual Assistant using AVA Library

Service Recipes > Virtual Assistant using AVA Library
04 Aug 2016

Building a Virtual Assistant (VA) microservice using the Agnostic Virtual Assistant Node.js library.

Agnostic Virtual Assistant or "AVA" is an NLP based Node.js library designed to support the creation of Virtual Assistant applications:

"The main purpose of AVA (Agnostic Virtual Assistant) is create a clever/fast assistant for any kind of context.

"Nowadays we can find a lot of assistants, and more and more in the coming years, all of us know that Apps in the future will be more conversational and less click/action. For that reason our approach is create an agnostic and reusable system for help developers to create any kind of virtual assistants."

Use Case

This recipe provides a simple example embedding the default AVA weather and movie actions in to an Eventn microservice.

Service Functionality

The service will support the ability to answer natrual language weather and movie questions such as"Will it rain in Bangkok tomorrow?". The microservice will parse and process the text using AVA's example Intents and Actions.


Eventn provides a GET function that is executed when an HTTP GET request is made. This is typically used for analytics retrieval however in this case, will simply return the response from the AVA library.

An example GET function is shown below. The example code includes the required actions and intents and then using the Eventn request query function argument, we can pass in a free text question. We setrequest.query.questionfor this purpose and pass that parameter to theava.listenfunction that returns a promise. Given Eventn JavaScript runtime supports promises, we can simply return the result, as well as catch any errors from downstream services used by AVA:

const Ava = require("ava-ia").default;
const intents = require("ava-ia/lib/intents");
const actions = require("ava-ia/lib/actions");
const ava = new Ava();
    .intent(intents.weather, actions.forecastYahoo)
    .intent(intents.movie, actions.movieDB);
function onGet(context, request) {
    return ava.listen(request.query.question)
        .then(state => ({
            status: "success",
            data: state.action
        .catch(err => ({
            status: "failed",
            data: err.message ? err.message : err
module.exports = onGet;

Example Request

With the AVA service in place, we can send natrual language questions via the HTTP GET request parameter"question"as described above:

    "question": "Will it rain in Bangkok tomorrow?"

As a URL encoded GET request:


Example Response

  "status": "success",
  "data": {
    "ms": 149,
    "engine": "yahoo",
    "entity": 4,
    "title": "Conditions for Bangkok, Bangkok, TH at 01:00 AM ICT",
    "url": "https://weather.yahoo.com/country/state/city-1225448/",
    "value": {
      "code": "12",
      "condition": "Rain",
      "temperature": [
      "date": "2016-07-31T00:00:00+00:00"

Get Started For Free

Get Started