aichaos / rivescript-js

A RiveScript interpreter for JavaScript. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com/
MIT License
377 stars 144 forks source link

save user responses in Google Sheets #347

Closed efretr closed 3 years ago

efretr commented 4 years ago

Hello, currently I can get responses saved in google sheets to respond to the users of my Bot, I do it with a function from javascript and an object in the bot's code.

sript:

chatbot.getDB('1Q1wQcNIozdPAdXi6q-JbDUVl3U5Lls-XXXXXXXX_id_my_sheet') .then(data => chatbot.db = data);

bot.rive:

object searchTerms javascript var filtered = chatbot.dbFilter(chatbot.db, "term", args); //used to be args[0] var terms = filtered.map(function(row) { return ${row.term}: ${row.definition} ${row.keywords}<hr>; }); var reply = "No encontre ninguna cohincidencia."; if (terms.length) reply = "Aqui esta lo que encontre.
" + terms.join(" "); chatbot.postReply(reply, 2000); < object

this works pretty well for me!!

My wish is how to save the responses of a user in the google sheets sheet?

gracias

kirsle commented 4 years ago

You might be able to collect these outside the bot and then do w/e to put them in google sheets:

bot.reply(username, message).then(reply => {
    // here we have: username, message, reply
    // put them in a Google sheet,
    // then send the reply
    chatbot.postReply(reply, 2000);
});