Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAILED: Integration code for Ionic 2 native #29

Open
ghost opened this issue Apr 20, 2017 · 2 comments
Open

FAILED: Integration code for Ionic 2 native #29

ghost opened this issue Apr 20, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 20, 2017

Don't want to use javascript lib npm install api-ai-javascript --save

Below integration fails the build:

import { Component } from '@angular/core';
import { NavController, AlertController } from 'ionic-angular';


declare var ApiAIPlugin:any;

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private alertCtrl: AlertController) {


  ApiAIPlugin.init(
        {
            clientAccessToken: "", // insert your client access key here 
            lang: "en" // set lang tag from list of supported languages 
        }).then(result => {
      // Could do something with the Response
      console.log(result);
    })
    .catch(err => {
      // Handle error
      let alert = this.alertCtrl.create({
        title: 'Error',
        message: err.message,
        buttons: ['OK']
      });
      alert.present();
    });
    


  }

 
@johndoe829
Copy link

johndoe829 commented May 1, 2017

"
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { TextToSpeech } from '@ionic-native/text-to-speech';

declare var ApiAIPlugin: any;

@component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {

constructor(public tts: TextToSpeech, public navCtrl: NavController) {

ApiAIPlugin.init(
  {
    clientAccessToken: "908415e3087c4a66afe961857aca8099", // insert your client access key here 
    lang: "en" // set lang tag from list of supported languages 
  },
  function (result) { /* success processing */ },
  function (error) { /* error processing */ }
);

}

sendVoice() {
try {
ApiAIPlugin.requestVoice(
{}, // empty for simple requests, some optional parameters can be here
function (response) {
this.tts.speak(JSON.stringify(response.result.fulfillment.speech), function () {

      },
        function (error) {

        })
    },
    function (error) {

    });
} catch (e) {

}

}

}

"

@m69
Copy link

m69 commented Oct 4, 2017

declare const ApiAIPlugin: any;

then....

platform.ready().then(() => {

      // API AI
      if (typeof ApiAIPlugin != 'undefined') {
        ApiAIPlugin.init(
          {
            clientAccessToken: "", // insert your client access key here
            lang: "en" // set lang tag from list of supported languages
          },
          result => { console.log('API AI ONLINE: ', result) },
          error => { console.log('API AI OFFLINE: ', error)}
        );
      }
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants