dialogflow / dialogflow-cordova-client

Cordova library for Dialogflow
Apache License 2.0
42 stars 23 forks source link

Can't find ApiAIPlugin #7

Closed riccardovittoria closed 9 years ago

riccardovittoria commented 9 years ago

Hello, When I try to invoke one of the functions I have an alert "ReferenceError: Can't find variable: ApiAIPlugin"

I have also build an application from scratch: cordova create hello com.example.hello HelloWorld cordova platform add ios cordova plugin add ai.api.apiaiplugin

Then I added the init in the onDeviceReady function of the index.js, substituted my keys. Last I just copied your function in the index.html and copied the simple div with the mic text.

No better than a clean start like that, but I always have the same error.

Could you help me with that? Thank you very much

sstepashka commented 9 years ago

Hello,

Can you attach your "index.js" file?

I'm trying you flow... all work

riccardovittoria commented 9 years ago

Sure, here you are, thanks!

On Apr 1, 2015, at 2:36 PM, sstepashka notifications@github.com wrote:

Hello,

Can you attach your "index.js" file?

I'm trying you flow... all work

— Reply to this email directly or view it on GitHub https://github.com/api-ai/api-ai-cordova/issues/7#issuecomment-88369720.

sstepashka commented 9 years ago

no attachments.

01/04/15 12:43, riccardovittoria пишет:

Sure, here you are, thanks!

On Apr 1, 2015, at 2:36 PM, sstepashka notifications@github.com wrote:

Hello,

Can you attach your "index.js" file?

I'm trying you flow... all work

— Reply to this email directly or view it on GitHub https://github.com/api-ai/api-ai-cordova/issues/7#issuecomment-88369720.

— Reply to this email directly or view it on GitHub https://github.com/api-ai/api-ai-cordova/issues/7#issuecomment-88370475.

riccardovittoria commented 9 years ago

Github does not recognize it and does not allow files different from images... Do you want to give me an email address?

Thank you, Riccardo

On Apr 1, 2015, at 2:45 PM, sstepashka notifications@github.com wrote:

no attachments.

01/04/15 12:43, riccardovittoria пишет:

Sure, here you are, thanks!

On Apr 1, 2015, at 2:36 PM, sstepashka notifications@github.com wrote:

Hello,

Can you attach your "index.js" file?

I'm trying you flow... all work

— Reply to this email directly or view it on GitHub https://github.com/api-ai/api-ai-cordova/issues/7#issuecomment-88369720.

— Reply to this email directly or view it on GitHub https://github.com/api-ai/api-ai-cordova/issues/7#issuecomment-88370475.

— Reply to this email directly or view it on GitHub https://github.com/api-ai/api-ai-cordova/issues/7#issuecomment-88370735.

riccardovittoria commented 9 years ago

Copied and pasted below:

var app = { // Application Constructor initialize: function() { this.bindEvents(); }, // Bind Event Listeners // // Bind any events that are required on startup. Common events are: // 'load', 'deviceready', 'offline', and 'online'. bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); }, // deviceready Event Handler // // The scope of 'this' is the event. In order to call the 'receivedEvent' // function, we must explicitly call 'app.receivedEvent(...);' onDeviceReady: function() { app.receivedEvent('deviceready');

    ApiAIPlugin.init(
        {
            subscriptionKey: "4e11d202-f0e4-45fc-953d-a742de6b76f7 ", // insert your subscription key here
            clientAccessToken: "506de649c3c946bbad9744b2cec92b6c", // insert your client access key here
            lang: "en" // set lang tag from list of supported languages
        }, 
        function(result) {/* success processing */ },
        function(error) {/* error processing */ }
    );

},
// Update DOM on a Received Event
receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');

    console.log('Received Event: ' + id);
}

};

app.initialize();

sstepashka commented 9 years ago

I'm paste you code to "index.js" and all work successfully!

Maybe update cordova by following command: $ sudo npm update -g cordova

Code from my example: https://gist.github.com/sstepashka/d81d1be2b2ef8dd2ba7f

riccardovittoria commented 9 years ago

Thank you for your response! So it's a cordova problem... I tried to update it but I still have the same error... Do you have any other idea? (I tried to use other plugins, like Capture, and cordova works perfectly)

Thanks again for your help

sstepashka commented 9 years ago

Can you send error log when you trying update cordova?

sstepashka commented 9 years ago

Maybe error in ruby version...

I'm using

$ ruby -v ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

riccardovittoria commented 9 years ago

No the error is "ReferenceError: Can't find variable: ApiAIPlugin" Cordova updates ok. But other plugins work, just the ApiAI ones does not, that's why I wanted to know if you have another idea of what could be the problem.

sstepashka commented 9 years ago

Which error is now? Is called successful callback?... or failure?

riccardovittoria commented 9 years ago

The error is always the same, it gives me an alert saying it cannot find the variable ApiAIPlugin..

On 02/apr/2015, at 01:12, sstepashka notifications@github.com wrote:

Which error is now? Is called successful callback?... or failure?

— Reply to this email directly or view it on GitHub.

sstepashka commented 9 years ago

Please, send all project to issue.

riyer15 commented 8 years ago

@sstepashka @riccardovittoria did you ever find a resolution to this issue? I am having a similar error "ReferenceError: ApiAIPlugin is not defined" and tried all the same methods mentioned here.

rvittoria90 commented 8 years ago

No, but that was long time ago. Api.ai has developed a great platform in the last year. I'm sure that they will be able to help you, write to the intercom console in your platform, they are very responsive.