Need help getting started with using ApiAiSDK

6 posts, 0 answers
  1. Doug
    Doug avatar
    17 posts
    Member since:
    Aug 2015

    Posted 16 Feb Link to this post

    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.

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Feb Link to this post

    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.

     
  3. Doug
    Doug avatar
    17 posts
    Member since:
    Aug 2015

    Posted 19 Feb in reply to Dimitrina Link to this post

    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.

     

  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 23 Feb Link to this post

    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.

     
  5. Doug
    Doug avatar
    17 posts
    Member since:
    Aug 2015

    Posted 02 Mar in reply to Dimitrina Link to this post

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

     

  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 07 Mar Link to this post

    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.

     
Back to Top