This is a migrated thread and some comments may be shown as answers.

Need help getting started with using ApiAiSDK

5 Answers 52 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Doug
Top achievements
Rank 1
Doug asked on 16 Feb 2016, 08:53 PM

This is a repost of my last forum post which I cancelled prematurely.

I'm trying to use the API AI natural language processing but I'm stuck at step one.  I've gone into the plug-ins on the project found the ApiAiSDK plugin in the telerik in the supported third party plug-in and selected it.  I'm using the web client to build the  app.  (No desktop environment).

The docs say to put in a call to init in the deviceready function
if (window.cordova) { 
document.addEventListener('deviceready', function () {
...
    cordova.plugins.apiAiSDK.init(
            {
                subscriptionKey: "xxxxxx",
                clientAccessToken: "xxxxx",
                lang: "en"
            },
            function(result) { console.log("worked");},
            function(error) { console.log("failed");}
    );
...
}
But I get an error saying Uncaught TypeError: Cannot read property 'apiAiSDK' of undefined.  Cordova.plugins doesn't exist when I look for it using the debugger.  I'm missing something basic here, but I don't know what.

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 19 Feb 2016, 12:32 PM
Hello Doug,

Do you eventually test this plugin in the device simulator or companion app? If so, then please note there are some limitations you should keep in mind in this case, for example most verified/custom plugins are not supported. Particular details are listed in the articles on:
Limitations of the Device Simulator
Limitations of the Companion Apps.

In case you experience problem when testing on device, then would please share more details on the exact device and OS you are testing on?

Regards,
Dimitrina
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Doug
Top achievements
Rank 1
answered on 19 Feb 2016, 05:16 PM

api.ai is one of the verified apps in the marketplace.  I understand there are limitations in the simulator and the companion app and I've been testing on an a samsung galaxy phone running android 5.1.1

I can't figure out what the plug-in should be referenced as.  Nothing I've tried in the documentation seems to work.

 

I've tried just ApiAIPlugin.init (from the telerik cordova docs)

     I get: Reference error

and cordova.plugins.apiAiSDK.init (which I found elsewhere)

      I get:  TypeError: Cannot read property 'apiAiSDK' of undefined, which means that cordova.plugins does not exist in the build.

Neither seems to work.  So I really don't know how to reference the plugin now that I've got it included in the app, or for that matter if it really is in the app.  I did include it in the managed plugins section.  So either the doc's are wrong or I'm missing something really basic here.

 

0
Dimitrina
Telerik team
answered on 23 Feb 2016, 04:22 PM
Hello Doug,

Performing several tests on my side, it seems that the plugin comes as undefined when the latest version of the ApiAIPlugin is installed.

What I can suggest for the moment is to use the previous version:  1.3.0.  That way, you should be able to access it once the onDeviceReady has passed:

ApiAIPlugin.init("YOUR_SUBSCRIPTION_KEY", "YOUR_CLIENT_ACCESS_TOKEN", function(result) {     /* success processing */ }, function(error) { /* error processing */ } );

Meanwhile, we will investigate the case further and provide a fix once we spot the reason for this problem.

Regards,
Dimitrina
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Doug
Top achievements
Rank 1
answered on 02 Mar 2016, 10:46 PM

Using the older version works.  Thanks for that and let me know when it's fixed.

 

0
Dimitrina
Telerik team
answered on 07 Mar 2016, 09:41 AM
Hi Doug,

To get notified immediately, I would suggest you to subscribe to watch the repository in GitHub and receive notifications on all updates done.

Regards,
Dimitrina
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
Apache Cordova
Asked by
Doug
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Doug
Top achievements
Rank 1
Share this question
or