Как исправить параметры в контексте неопределенной проблемы в помощнике Google - PullRequest
0 голосов
/ 08 апреля 2019

У меня проблема с получением параметров в контексте.

Например, у меня есть 2 намерения, такие как «Намерение вопроса» и «Намерение ответа».

В Intent In у меня есть параметры с продолжительностью жизни в контексте, но в Intent Intent я получаю, что контекст не определен.

Примечание. В разрабатываемой версии работает нормально. После развертывания в рабочей среде эта проблема возникла.

Вот код:

Цель вопроса:

var conv = agent.conv();
conv.ask("What's your age?");

let context = {'name':'data_req','lifespan':'5','parameters':{'userid':12,'country':'IN'}}; 

agent.context.set(context);
agent.add(conv)

Намерение ответить:

var conv = agent.conv();
let context = agent.context.get('data_req');
let userid = context.parameters['userid'];

Я получаю параметры в контексте не определено

1 Ответ

0 голосов
/ 09 апреля 2019

Несколько вопросов, для контекста:

  1. Вы опробовали Действия на кодовых ярлыках Google? ( первый уровень , второй уровень , третий уровень )

  2. Вы следуете какой-либо учебник?

Я спрашиваю, потому что мне любопытно, почему вы храните объект conv в его собственной переменной, и я не вижу методов Dialogflow .intent () для обработки ваших намерений. Пример выполнения, с которым я знаком, выглядит так ...

'use strict';


// Import the Dialogflow module and response creation dependencies from the
// Actions on Google client library.

const {
  dialogflow,
  Permission,
  Suggestions,
  BasicCard,
  List,
  Image
} = require('actions-on-google');


// Import the firebase-functions package for deployment.

const functions = require('firebase-functions');


// Instantiate the Dialogflow client.

const app = dialogflow({debug: true});


// Handle the Dialogflow intent named 'Default Welcome Intent'.

app.intent('Default Welcome Intent', (conv) => {
  conv.ask(`Hey, welcome to the Greeting Card Store! You can browse and buy handmade cards, available to ship anywhere in the contiguous United States. What kind of card are you looking for?`);
  conv.ask(new Suggestions('Birthday', 'Romantic'));
});


// Handle the Dialogflow intent named 'favorite color'.
// The intent collects a parameter named 'color'.

app.intent('favorite color', (conv, {color}) => {
    const luckyNumber = color.length;
    // Respond with the user's lucky number and end the conversation.
    conv.close('Your lucky number is ' + luckyNumber);
});


// Set the DialogflowApp object to handle the HTTPS POST request.

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
...