Best practice for storing the chatbot's answers - node.js

My issue is that I don't know what is considered a good practice for storing the chatbot's answers. I do not wish to have the answer in plain text inside the bot.dialog() in code like this:
bot.dialog('Greeting', session => {
session.endDialog('Hello, I'm a bot.');
});
... But instead fetch the answers from a database or a local file.
Since the bot is supposed to run in Azure, I've been looking at Azure Cosmos DB with MongoDB, but are there better alternatives? Given the simplicity of the database, would be a better practice to store the bot's answer in a local JSON file and store it in the same catalog as my app.js file?
The bot is supposed to be an FAQ bot, so the DB/file would mostly consist of answers that the bot is going to give for the different types of dialogs. There will most likely be no relation between the data.

Related

Visibility of files and global variables using pyTelegramBot

So i've been working on a chatbot on telegram using python (pyTelegramBot API), and started to look into saving users data in a database (.db) file.
My question can be devided into two questions:
While asking information from the user - the bot stores the input data from the user in a global dictionary that stores the user data. Now as far as I know - using a global variable is bad practice, but that was the best way I found to deal with storing the data across different functions.
I also read that using a User class will be better - but I fail to understand how a global object would be better. Maybe I'm missing something very obvious here but this is really stopping my project from advancing
About using .db file (SQLite3) - I guess that if someone would want to gain access to my db file, he would need to go on the file server and open the file itself. is there any way I can protect this file from being opened by anyone but me and my bot?
Thank you!

Where does Dialogflow store simple responses?

For example: I add a simple response to an intent with Dialogflow interface,
like this.
This response is associated with my intent and my agent, but where is it stored? Is there some google db? Can I access all the agent data stored by dialogflow?
I can't find any hints in the documentation.
Where is it stored? Is there some google db?
There is a data store of some sort, just like most things are stored in a database or data store of some sort. But that doesn't mean that it is a conventional database in the way you may think about it.
It also doesn't mean that you would have access to the database directly.
Can I access all the agent data stored by dialogflow?
Depends what you mean by "all the agent data". Everything that you build using the web interface (the Intents and Entities, for example) is available to you. You can export it as a zip file that contains various JSON files with the configuration. You can also use the Dialogflow API to get various parts of your configuration.

Methods of Storing User Data Online

I have been considering the best process to store user data online.
An example of the usage I need:
Think of it as a collaborative story-writing app. One user writes, say, a paragraph of the story. They "submit" this paragraph and all the other uses of the app who have subscribed to this user will be near-immediately notified and will be able to check their app for the update. The subscribed users can then write their own paragraph, and submit it, which alerts the original poster and all other users.
I mostly just need the database functionality. It would be fantastic if I could make use of Facebook's friends functionality, but I guess I could use both of the below approaches...
The approaches I have considered:
Using Unity's Facebook.API
When I was originally conceiving my concept a friend suggested using the Unity FB.API as a way to store the information online. However from what I understand FB can't really be used as database, which is what question one involves.
Hosting my own Server
I am familiar with Node.js, and have used it to create and manage small servers, just for University assignments. So I understand the basics of whats involved, and the way I see it I have two options here: paying for a server or hosting one on my home PC (just for early development).
If I do it this way, I could save the data in JSON for example and read it to the user as required.
{
"story": {
"name": "Nice Story",
"paragraph1": {
"userID": 2366,
"text": "One day I wrote a nice story"
},
"paragraph2": {
...
},
...
}
}
But probably with the paragraphs in an array! Similarly I could also store stories/users/paragraphs in Mongo etc.
So, to get to the Question
Simply put, there are three parts:
Can Unity's FB.API (or any Facebook thing) be used to store information like I require?
Would using a Node.js server be a more effective way to achieve my functionality?
Is there another way?
Thanks in advance for your time!
No, the Facebook API is not a custom database where you can store your own stuff.
A Node.js server would be "one" way to store data. For example, in a .json file, or in a MongoDB database, or whatever. That´s pretty opinionated though. You can use any server/technology you want.
There are hundreds of other ways, a simple one would be Firebase.
If you can pay around 5-10 bucks a month for a hosting site, most have an integrated database that you can use to store data.

Storing files on a datastore and getting back their location to store for later retrieval

I will need to store photo's on a datastore, store the location in Mongo so I can retrieve it later to display. What is a good way to go about doing this? If I just google I end up getting information on accessing the files in node itself.....
At this point I am not sure what datastore I will use, for now just on another server I have, Ubuntu Server.
I made something like what you need. I had to store photos on s3 and store the path on mongo. If you use amanzon too, they provide a sdk, that contains all possible functions for interactions with the cloud. So you'll need a way to work with asynchronous tasks when store the data in the cloud, I used async module to manage the functions. I hope I gave you some direction where go to. I can't help you code, once I don't know your business rules, good lucky

mongoose: send data back without saving

I just started using node, backbone and mongoose not so long ago to create my first web app.
At the very beginning, I followed tutorials, and used backbone client side to define models. Those models mirror my mongoose schemas server side.
When I run schema.save() on one of my models, my data is automatically sent back to the client, with an _id.
But now that my app is almost finished, I realize that I don´t really need to save anything, as the only thing I do is query an api, and the data doesn´t have to be reused.
So my question is, what is the best way to keep the same mechanisms, but without saving anything?
The end reason is that I plan to run the app on an ec2 instance, and knowing that I don´t need to save anything, I think it is more beneficial to reduce the IO usage by not having any database.
Thanks, and sorry if the question seems dumb.

Resources