Sunday, August 7, 2016

BotKit OAuth Login

When a user starts a conversation with your business, you may want to identify her as a customer who already has an account with your business. To help with this, we have created a platform-agnostic secured protocol to link and unlink the messaging end-user identity with your business user identity.

OAuth-style LogIn allows you to invite users to log-in using your existing authentication flow thus to provide a more secure, personalized and relevant experience to users.

To request a Log In return a special message of type LoginOAuthEvent from any applicative webhook.
As this is an interactive message it can only be the last in the list of returned messages and there can only be a single interactive message in the list.

Here is an example of such a reply:

{
    "botkitVersion": "0.3.0", 
    "messages": [
        {
            "_type": "LoginOAuthEvent", 
            "loginSuccessHook": {
                "webhook": "flight_boarding_pass"
            }, 
            "text": "Please Login in first", 
            "webLoginUrl": "https://chat.evature.com/demo_login"
        }
    ]
}
  • _type - Must be LoginOAuthEvent
  • loginSuccessHook - a JSON object with either webhook - an enumeration of an existing webhook, or url
  • text - any text message - mandatory.
  • webLoginUrl -  a URL to the web login page.
The end user will be presented with a log in request. Once she clicks on it she will be redirected outside the messaging platform and into the a web browser window with the business specific log in process.

The URL webLoginUrl will be extended with a query parameter called redirect_uri.
If the log in is successful, redirect the browser to the redirect_uri specified in your callback to complete the flow, and append a new authorization_code query parameter. Eva will add the contents of authorization_code to the subsequent
applicative webhook calls as a new key called loginData.

Detailed BotKit docs can be found here: http://www.evature.com/docs/botkit.html

Tuesday, June 28, 2016

Introducing the Eva Travel BotKit

The Eva BotKit enables building a single AI assisted Bot for providing applicative Travel functionality across all messaging platforms with a bot platform API. BotKit bundles Eva’s Natural Language Understanding and nonlinear Dialog Management features with robust cloud based spelling correction. Furthermore, the Eva API reply is automatically parsed and dialog is handled by Eva. The backend application is only called upon to implement applicative directives, such as ShowBoardingPass or PerformFlightSearch. Applicative integration is done via fully customizable webhooks. Eva automatically reformats your applicative webhook replies to comply with all quirks of the different messaging platforms so you don’t have to integrate separately with each one.

It takes 5 minutes to get your new Bot to answer Hellos on Facebook Messenger, Telegram LINE or Kik!


Integration with all messaging platforms consists of the following steps:

  1. Create a new Bot
  2. Add a Chat Service Integrations
  3. Implement applicative webhooks

The BotKit provides seamless integration with the following platforms:
  • Facebook Messenger
  • Telegram
  • LINE
  • Kik
  • WeChat (Beta)
  • Slack (Beta)
  • SMS (Beta)


Eva defines many webhook functions for applicative requests that may be queried by the end users. This is usually existing functionality in your backend servers that the developer needs to “wire” to the corresponding webhook post.
Here are some examples:
  • Perform a Flight Search
  • Perform a Hotel Search
  • Show a Boarding Pass
  • Show an Itinerary
You can simply ignore the applicative webhooks that are non-applicable to your backend. Eva will automatically reply to end users explicitly requesting these services with a “not supported” message.



To get started, log in to https://chat.evature.com/botkit using your Eva credentials.
For free API access please register here:

Detailed docs available there: http://www.evature.com/docs/botkit.html

Enjoy botting!

Sunday, May 1, 2016

VoiceKit for Android update - version 2.1.424



We've just released a new version of VoiceKit for Android - 2.1.424.

Features:
  1. Return EvaResult from the applicative callbacks -
    This version allows returning a custom reply from the applicative callbacks, thus allowing the application to modify the text spoken or displayed by Eva.
    This allows for new types of integrations, for example - allowing the application to answer questions asked by the user.
  2. Example App -
    the SDK is now bundled with a simple example app, featuring the different applicative interfaces and different return values.

We've also started using the jitpack.io artifact repository.  This allows the developers to setup a specific version in the build.gradle file or use the latest version - and Gradle will handle fetching the needed dependencies.

To use it follow these two steps:

  1. Add justpack.io repository:
    In your root build.gradle at the end of the allprojects repositories:
    maven { url "https://jitpack.io" }
  2. To  your app build.gradle dependencies add one of the following:
    compile 'com.github.evature:android:2.1.424'

    // or for the latest backwards compatible version:
    compile 'com.github.evature:android:2.0.+'  

    // or for the latest and greatest version:
    compile 'com.github.evature:android:master-SNAPSHOT'   


Note this version (2.1.+)  is NOT backwards compatible. 
However, it should be a very small effort to update the code to compile with the new version.

The non compatible changes include:
  1. App interfaces are are now prefixed with "Eva" (eg. EvaHotelSearch instead of HotelSearch).
    Since Java does not allow import aliasing, this will eliminate the problem of having similar named classes in the app.
  2. The different fields in the Eva classes are now consistently camel case (as per Java coding standards).
  3. App search interface function parameters are slightly different - instead of passing many parameters to the search function, an "attributes" object is passed which contains different attributes.
    eg.  instead of using the "minStars" parameter use "attributes.minStars".
  4. The app interface functions now return an EvaResult class and are not void functions. Simply return null for the default behaviour.



For any questions or requests, please don't hesitate to ask.

Monday, October 19, 2015

Introducing the Eva VoiceKit for iOS

Screenshot of the Eva VoiceKit for iOS
A few months ago we introduced the Eva VoiceKit for Android and today we are adding an iOS library with the same functionality. Use VoiceKit to voice-enable a travel application in a few of hours of simple integration.

VoiceKit for iOS is a culmination of many iPhone integrations of the Eva Speech Recognition and Natural Language Understanding SDK with mobile Travel applications.

Eva VoiceKit for iOS comes batteries-included and bundles everything a travel application application needs:
  • Very large vocabulary cloud-based DNN Speech Recognition
  • Deep Learning based Natural Language Understanding
  • Dialog Management - Eva automatically asks questions and converses with the end users in natural language
  • Beautiful Voice Chat User Interface Overlay with Semantic Highlighting
  • Insights and Analytics Dashboard
By lowering the barrier to entry to voice enabling Travel applications we addressed the #1 customer concern with expensive development resources.
Achieve complete voice integration in less than a single developer-day.
With the Eva VoiceKit for iOS you can add a cutting edge voice interface to an iOS travel application with super simple integration.

Take advantage of the precision of the latest Deep Learning algorithms delivering near human intelligence.

The user interface includes informative animations while conforming to the latest design guidelines and is fully customizable to match the travel application's theme.

The SDK is open source and is available for immediate downloads at https://github.com/evature/ios

Fork us on Github!



PS - A PhoneGap (Apache Cordova) version of VoiceKit for iOS and for Android is coming soon!

Monday, July 13, 2015

Introducing the Eva VoiceKit for Android


Voice enable your travel application in a couple of hours using the latest Eva VoiceKit SDK.
The VoiceKit is a culmination of many integrations of the Eva Speech Recognition and Natural Language Understanding SDK with mobile Travel applications.
The Eva VoiceKit comes batteries-included and bundles everything your application needs:
  • Speech Recognition
  • Natural Language Understanding
  • Dialog Management
  • Voice Chat User Interface Overlay with Semantic Highlighting
  • "OK Google" Integration
  • Insights and Analytics Dashboard
We tried to lower the barriers to entry to voice enabling Travel applications, and the #1 customer concern was expensive development resources.
Our goal is to achieve complete integration in less than a single developer-day.
With this new release you can add a cutting edge voice interface to your travel application with super simple integration.

Take advantage of the precision of the latest Deep Learning algorithms delivering near human intelligence.

The beautiful user interface conforms to the latest Material Design guidelines and is fully customizable to match your application's theme.

The SDK is open source and is available for immediate downloads at https://github.com/evature/android

Fork us on Github!


Wednesday, January 28, 2015

The fastest route between voice search and your app


A very cool feature you can add to your Android app is integrating with Google's voice search.

When enabled, your users will be able to say to their phone:

  "Ok Google, search for flights from NY to LA on MyCoolTravelApp"

The good news is this integration is very simple, and Eva is a perfect match to parse any text provided by the user.

3 small steps are necessary:

1. To AndroidManifest.xml  change the your Activity entry with:

<activity
            android:name="com.yourcompany.YourSearchActivity"
            android:launchMode="singleTask"    >
      <intent-filter>
           <action android:name="com.google.android.gms.actions.SEARCH_ACTION"/>
           <category android:name="android.intent.category.DEFAULT"/>
      </intent-filter> 
</activity> 

2. To your search activity - add:

@Override
protected void onNewIntent(Intent intent) {
     super.onNewIntent(intent);
     setIntent(intent);
}

3. at the end of onResume method add:

Intent intent = getIntent();
if ("com.google.android.gms.actions.SEARCH_ACTION".equals(intent.getAction())) {
         // search from Google Voice Search:
         // similar to clearing session and then handling voice-recognition results
         eva.resetSession();
         eva.stopSearch();
      
         // When starting a new session you'd want to clear the chat screen
         clearChatHistory();
         String searchString = intent.getStringExtra(SearchManager.QUERY);|
         // Add the user chat and initiate an eva search
        addUserChat(searchString);
        eva.searchWithText(searchString, null, false);
        // clear the intent - it shouldn't run again when resuming
       onNewIntent(new Intent());
}

Note:
  1. If your search activity is not the top level activity in your app you may wish to setup a back stack - see the relevant Android documentation.
  2. The Google Voice integration will not work until you publish your app to the Play store with the updated AndroidManifest.
    To test it can send the intent via adb, for example:
    adb shell am start -a com.google.android.gms.actions.SEARCH_ACTION -e query Flights from NY to LA <app package name here>

Tuesday, January 27, 2015

Using Eva's Android SDK

This post will describe how to integrate Eva in an Android Project.

SDK Structure
The SDK comes with three directories:

  • EvaAPIs: The Eva SDK 
  • android_demo:  A minimal demo that allows sending text to Eva and displays the response on the screen.
  • android_search: A larger sample application which demonstrates Eva’s usage for searching for hotels. The application can search and book hotels using Expedia API. It has a Google map display, however to use it you must use your own API keys (Expedia, Google maps, Vayant).

Download or clone the SDK from:  https://github.com/evature/android


How to use the SDK

  1. Import the EvaAPIs project to your Eclipse workspace as an existing Android Project.
  2. Add EvaAPIs as a library to your own project -
    1. Right click your project, choose “properties”. 
    2. Click “Android” in the left side menu.
    3. Add a reference to the EvaAPIs project.
  3.  Add required permissions to your AndroidManifest:

    Required permissions:
        android.permission.INTERNET
        android.permission.ACCESS_FINE_LOCATION
        android.permission.ACCESS_COARSE_LOCATION

    If you want to use the voice based search you also need:
        android.permission.RECORD_AUDIO
At this point you can start using Evature SDK -

A minimal integration is very simple:
  1. extend EvaBaseActivity
  2. override the onEvaReply listener callback to handle Eva reply
  3. call "searchWithText" or "searchWithVoice" methods to send user input to Eva.



Class Reference


EvaApiReply

Reply object for Eva, populated into java classes.
Documentation for it can be found  at:
http://www.evature.com/docs/response.html#api-reply-in-depth


EvaBaseActivity

Base activity for activities that use the Eva SDK. 


Note: 
Many Android frameworks and libraries require you to extend your main activity from a base class (eg. RoboGuice, ActionbarSherlock, more…) . This is problematic since Java does not allow multiple inheritance and so only one such library can be used. Eva SDK is compatible with such libraries - you can use Eva without extending the base class but it requires more “wiring” and isn’t recommended if not required. See the section below on using Eva without extending from a base class.  

public methods:


void speak(String sayIt, [boolean flush])
Uses TTS to say a string.  Eva will delay the speech until the TTS (Text to speech) engine is ready, so calling speak(“hello”)  in onCreate of the activity may be delayed by a few seconds.
If the flush parameter is true (defualt) then calling a second speak while a first is still playing will stop the first speech.   eg. use speak(“”) to stop the speech.

void searchWithVoice(Object cookie, boolean editLastUtterance)
Eva will start a recording of user. When silence is detected (after a period of non-silence) the recording is automatically stopped.
The user speech will be used as input text by Eva to generate the result.
It is essential to stop TTS before starting a recording - call speak(“”)
It is essential to let the user know he is being recorded -
We strongly recommend to play a short “beep” before starting the recording, and also show a visual mark that a recording is ongoing. If you add a visual mark you should override speechResultOK and speechResultError (see below) to disable the visual mark when the recording completes.
See “visual feedback of ongoing recording” below for optional visual feedback provided by Eva.

Parameters:
  • editLastUtterance:  tell Eva the current input replaces the previous one. 
  • cookie: The cookie parameter will be returned untouched with the search result callback, this can be used to store data known when the search is triggered and which useful when the result arrives. Pass null if not needed.

void searchWithText(String text  , Object cookie, boolean editLastUtterance)
Send a query to Eva with text instead of voice. The result will trigger a callback onEvaReply  (see below).
Parameters:
  • text: Text to query for 
  • cookie, editLastUtterance: see above.


void replyToDialog(int replyIndex, Object cookie)
When confronted with a multiple choice question in an Eva Reply, the answer chosen by the user should be sent using this function.

boolean isNewSession()
Returns true if the current state is of a new session.

void resetSession()
Start a new session.

void cancelSearch()
Stop an ongoing search - no callback will be activated.

Configuration:
The class includes different getters and setters for configuration of Eva - for example:
apiKey, siteCode - the credentials to use Eva.
locale -  see http://www.evature.com/docs/request.html#locale.
language - auto translated input_text and EvaReply, and also change the TTS language.
context - see http://www.evature.com/docs/request.html#scope


Method Overrides:

public void onEvaReply(EvaApiReply reply, Object cookie)  
Override this method to get the EvaReply from a voice or text search. Cookie is the object that was passed to the search request which triggered this reply.

public void newSessionStarted(boolean selfTriggered)
Called when a new session has started. If the parameter is true this is in response to a  resetSession call, otherwise it means Eva’s logic decided that the previous request started a new session.

speechResultOK
this method is called when a valid response is returned. The first parameter is the response string that can be passed to EvaApiReply constructor. 

speechResultError
called when there is an error (such as connection timeout) and the parameter is the error message. The default behaviour is to show the message in a Toast.



Advanced use cases

Using Eva without extending a base class

Many Android frameworks and libraries require you to extend your main activity from a base class (eg. RoboGuice, ActionbarSherlock, more…). This is problematic since Java does not allow multiple inheritance and so only one such library can be used. 

To overcome this problem you can use Eva without extending a base class. To do so follow the following steps:

Create a com.evaapis.EvaSearchReplyListener.
Create a field of type EvaComponent  - the constructor requires two parameters:  Activity and EvaSearchReplyListener.
In your activity’s onCreate, onResume, onPause, onActivityResult, onDestroy methods call the matching methods on the EvaComponent field.  
At this point you can use the methods described above for EvaBaseActivity - but activate them on the EvaComponent object or EvaSpeechComponent.



Visual feedback of ongoing recording

While the recording is ongoing, you can poll Eva for data such as current volume or even a buffer of the previous samples. This data can be visualized on the screen, for example brighter background color on higher volume. 

Data for visualization can be queried from the class SpeechAudioStreamer which can be retrieved from the EvaSpeechComponent using 
Polling the recorder state and updating GUI can be done using android.os.Handler class. 
For example:

updateLevel = new Handler()  {
   @Override
   public void handleMessage(Message msg) {
      SpeechAudioStreamer  speechAudioStreamer = speechSearch.getSpeechAudioStreamer();
      //   can read audio state from speechAudioStreamer here and update GUI based on it
      sendEmptyMessageDelayed(0, 50); // poll the statistics every 50ms
      super.handleMessage(msg);
   }
};
// send initial message to start the polling
updateLevel.sendEmptyMessageDelayed(0, 50);
// start the recording

Eva provides a widget to visualize the wave-form of the recording, the class SoundView. To update it run:

soundView.setSoundData(  speechAudioStreamer.getSoundLevelBuffer(),
                         speechAudioStreamer.getBufferIndex()
);