Я новичок в диалоговом потоке, и к нему я добавляю несколько уроков и следую построчно этой инструкции (https://medium.com/google-developer-experts/how-to-use-google-sign-in-for-the-assistant-b818f3de9211) = Я не могу это сделать!
Это мои намерения
Мы приветствуем пользователя, а затем спрашиваем его, хочет ли он попросить песню, но перед запуском веб-крюка нам нужно запросить его разрешение, чтобы узнать его имя и почту, и Я не понимаю, как заставить это работать.
Это индекс. js
// See https://github.com/dialogflow/dialogflow-fulfillment-nodejs
// for Dialogflow fulfillment library docs, samples, and to report issues
'use strict';
const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const axios = require('axios');
const https = require('https');
process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
function callApi(url, result) {
return axios({
method: 'post',
url: url,
data: result
});
}
function welcome(agent) {
agent.add(`Bienvenido a la primera playlist armada en comunidad!`);
agent.add(`¿Querés pedir una canción?`);
agent.add(new Card({
title: 'Yourbans LIVE (by #RockMyPost)!',
imageUrl: ‘text.png',
text: 'Sé parte de la primera playlist colaborativa 24/7',
buttonText: 'Escuchá en VIVO',
buttonUrl: 'http://yourbans.com/'
}));
agent.add(new Suggestion(`PEDÍ UNA CANCIÓN`));
}
function fallback(agent) {
agent.add(`¿Podrías repetirlo, por favor?`);
agent.add(new Suggestion(`PEDÍ UNA CANCIÓN`));
agent.add(new Card({
title: 'Yourbans LIVE (by #RockMyPost)!',
imageUrl: ’test.png',
text: 'Escuchá en vivo la primera playlist colaborativa 24/7',
buttonText: 'Escuchá Yourbans Live',
buttonUrl: 'http://yourbans.com/'
}));
}
function otraCancion(agent) {
agent.add(`Gracias! Nos vemos pronto.`);
agent.add(new Card({
title: 'Yourbans LIVE (by #RockMyPost)!',
imageUrl: ‘test.png',
text: 'Escuchá en vivo la primera playlist colaborativa 24/7',
buttonText: 'Escuchá Yourbans Live',
buttonUrl: 'http://yourbans.com/'
}));
}
function askSongHandler(agent) {
const apiUrl = ‘webhook-currentlyworking-perfect’;
const apikey = ‘xxxxxxx’;
const song = agent.parameters.song;
const artist = agent.parameters.artist;
const hashtag = "#rockmypost";
const playlist = '#rockmypost';
const creatorImageUrl = ‘test.png';
const creator = 'PediUnaCancion';
const qtext = hashtag + " " + artist + " + " + song;
return callApi(apiUrl, { apikey: apikey, qtext: qtext, playlist: playlist, creatorImageUrl: creatorImageUrl, creator: creator })
.then((resultados) => {
// console.log(resultados.data);
// agent.add(`Tu canción fue: `+resultados.data.result);
if (resultados.data.result === 'ACEPTADA'){
agent.add(`Gracias!`);
agent.add(`"`+resultados.data.cancion+`"` + ` de ` + resultados.data.artista + ` se agregará a la Playlist y la podrás escuchar a continuación.`);
agent.add(new Card({
title: resultados.data.cancion,
imageUrl: resultados.data.urlAlbumImage,
text: resultados.data.artista,
buttonText: 'Escuchá tu canción!',
buttonUrl: 'http://yourbans.com/'
}));
agent.add(`¿Querés pedir otro tema?`);
agent.add(new Suggestion(`PEDÍ OTRA CANCIÓN`));
}
else {
agent.add(`Lo siento! Tu tema no fue encontrado.`);
agent.add(`¿Querés volver a intentarlo?`);
agent.add(new Suggestion(`PEDÍ UNA CANCIÓN`));
agent.add(new Card({
title: 'Yourbans LIVE (by #RockMyPost)!',
imageUrl: ‘test.png',
text: 'Escuchá en vivo la primera playlist colaborativa 24/7',
buttonText: 'Escuchá Yourbans Live',
buttonUrl: 'http://yourbans.com/'
}));
}
})
.catch(function (error) {
agent.add('ERROR' + error);
console.log('esto es un fucking error',error);
});
}
let intentMap = new Map();
intentMap.set('PediUnaCancion - yes', askSongHandler);
intentMap.set('PediUnaCancion - no', otraCancion);
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
agent.handleRequest(intentMap);
});
Это пакет. json
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "12"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.12.0",
"firebase-admin": "^8.10.0",
"firebase-functions": "^3.3.0",
"dialogflow": "^1.2.0",
"dialogflow-fulfillment": "^0.5.0",
"axios-https-proxy-fix": "0.17.1"
}
}
Это последняя проблема, когда Google Approval загрузил ее в качестве действия. Я имею дело с этим с прошлой пятницы, и я сожжен!
Кто-нибудь может мне помочь?