Git Product home page Git Product logo

fulfillment-firestore-nodejs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fulfillment-firestore-nodejs's Issues

Dialogflow fulfilment Webhook timeout on Firestore save and read

I tried out the following fulfilment example pattern but adapted to my dataset. However, I get a webhook timeout error. The agent.add('..message..) is not executed when called within the .then (...) after the firestore read and write.

The issue comes only in Firestore and not in Firebase for an equivalent datamodel. The Firebase cloud function execution time in console log shows as about 4.5 sec in Firestore and 2.5 sec in Firebase (on a separate note, it is surprising why the execution time not in milli-sec for both Firestore and Firebase).

Example function here:
https://github.com/dialogflow/fulfillment-firestore-nodejs/blob/master/functions/index.js

Error details - pasted part of it from the 'Diagnostic Info' in dialogflow simulator:
......
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 5001
},
"languageCode": "en"
},
"webhookStatus": {
"code": 4,
"message": "Webhook call failed. Error: Request timeout."
}
}

Unable to receive date an spreadsheet API from Firebase that is connected with Dilaogflow

Unable to receive date an spreadsheet API from Firebase that is connected with Dilaogflow.

Here is my Index.js
"""
'use strict';

const functions = require('firebase-functions');
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');
const axios = require('axios');
const Twilio = require('twilio');
const nodemailer = require("nodemailer");
const mysql = require('mysql');

//const transporter = nodemailer.createTransport({
// service: 'gmail',
//auth: {
// user: 'EMAIL',
//pass: 'PASSWORD'
//}
//});

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 getSpreadsheetData(){
return axios.get('https://sheetdb.io/api/v1/bzg9fw0dmp8ck');
}

function welcome(agent) {
const name = agent.parameters.name;
return getSpreadsheetData().then(res => {
res.data.map(person => {
if(person.Name === name)
agent.add(Here are the details for ${name}. Gender: ${person.Gender}, Home: ${person.Home}, Subject: ${person.Subject}, Activity: ${person.Activity});
});
});
}

function fallback(agent) {
agent.add(I didn't understand);
agent.add(I'm sorry, can you try again?);
}

function feedbackHandler(agent){
/const {
name, email, phone, age
} = agent.parameters;
/
const {
name, email, phone, text
} = agent.parameters;

const data = [{
  Name: name,
  Email: email,
  Phone: phone,
  Feedback: text
}];
console.log(name);
console.log(email);
console.log(phone);
console.log(text);
return axios.post('https://sheet.best/api/sheets/76c728d6-ec36-466d-868a-504793f23dca', data)
.then(res=>{
  console.log("save success");
}).catch(err=>{
  console.log("error",err);
});

}

//function sendEmailHandler(agent){
//const { email, name } = agent.parameters;

//const mailOptions = {
  //  from: "Axlewebtech", // sender address
   // to: email, // list of receivers
   // subject: "Email from chatbot", // Subject line
   // html: `<p> Hello ${name} </p>`

// };

// transporter.sendMail(mailOptions, function (err, info) {
// if(err)
// {
// console.log(err);
// }
//});

// }

// Run the proper function handler based on the matched Dialogflow intent name
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
intentMap.set('feedback', feedbackHandler);
//intentMap.set('sendEmail', sendEmailHandler);
// intentMap.set('your intent name here', yourFunctionHandler);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
});
"""

Here is package.js
"""
{
"name": "dialogflowFirebaseFulfillment",
"description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
"version": "1.1.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
"deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.1",
"twilio": "3.39.3",
"axios": "0.19.0",
"nodemailer": "6.3.1",
"mysql": "2.17.1"
}
}
"""

In firebase It's Showing this error

dialogflowFirebaseFulfillment | Function execution took 1522 ms, finished with status: 'crash'

dialogflowFirebaseFulfillment Error: No responses defined for platform: null at V2Agent.sendResponses_ (/srv/node_modules/dialogflow-fulfillment/src/v2-agent.js:243:13) at WebhookClient.send_ (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:505:17) at promise.then (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:316:38) at at process._tickDomainCallback (internal/process/next_tick.js:229:7)

Collection Querying with DialogFlow

Is there currently or will there be support for querying collections with DialogFlow?

I'm running into an issue where the query snapshot doesn't.

I'm returning
.get().then(querySnapshot => {})with Promise.resolve/reject.

From what I've seen (and these docs) only .collection.doc is working.

Unable to link

I know this is probably an issue with me not understanding the project. I am newer to this type of programming (coming from PLC programming). I have an implementation where I have an intent on Dialogflow called Start Command which has a list of commands tied to a number. The name of the action is startCommand and the parameter name is number. I have seen the attached code but am not sure what needs to be changed to allow this code to work for my implementation. I have tried switching out some of the commands and get webhook errors (no surprise). Can someone clarify what needs to be changed and what all it affects? Thanks

how to write in a certain uid of user

I am trying to implement a chatbot using dialogflow and flutter. I need to save some data from the user at different points and also return this data to the user. In this process, user's uid will play an important role as I am trying to save data from user using doc id as user's uid. So my problem is how to get user uid in dialogflow fulfillment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.