0

我需要让用户登录。怎么做?我没有从谷歌搜索结果、StackOverflow 和 youtube 中得到一个可行的例子。

'use strict';

const functions = require('firebase-functions');
const { WebhookClient } = require('dialogflow-fulfillment');
const { Card, Suggestion } = require('dialogflow-fulfillment');
const { dialogflow, SignIn } = require('actions-on-google');
const app = dialogflow({
    // REPLACE THE PLACEHOLDER WITH THE CLIENT_ID OF YOUR ACTIONS PROJECT
    clientId: '93232567633.apps.googleusercontent.com',
});

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements




exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
    const agent = new WebhookClient({ request, response });
    console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
    console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

    function welcome(agent) {
      app.intent('ask_for_sign_in_detail', (conv) => {
        conv.ask(new SignIn());
      });   

        agent.add(`Welcome to my agent!`);
    }

    function fallback(agent) {
        agent.add(`I didn't understand. feel free to ask anything related to aquarium shop. we are always ready to help you. You can ask the fish price or delivery available location details etc. Is there anything else?`);
        agent.add(`I'm sorry, would you please try again?`);
    }

    function androidApp(agent) {
        agent.add(`Aquarium Shop app is available in google play Store. Is there anything else i can assist you?`);


    }
    var showLogCard = false;



    // Run the proper function handler based on the matched Dialogflow intent name
    let intentMap = new Map();
    intentMap.set('Default Welcome Intent', welcome);
    //intentMap.set('AndroidApp', androidApp);
    intentMap.set('Default Fallback Intent', fallback);

    // intentMap.set('your intent name here', googleAssistantHandler);
    agent.handleRequest(intentMap);
});
4

0 回答 0