Best way to store replies from users in Facebook chat?

Create a Facebook Messenger bot using Claudia JS and an AWS Lambda deployment plan.

I want to ask the user a series of questions.

When the user answers with an answer, I need to save it for later, and as soon as I have all the necessary information, I will pass the answers to the function.

What is the best way to save this information?

I was thinking of some kind of caching layer like redis, but since it is stored in RAM, I will lose it when the lamda server shuts down. Mongodb seems to have a lot of connection overhead, but at least it will be persistent.

Maybe just a simple mySQL server?

How is everyone doing this? I feel that there is a simple solution that I am missing.

+4
source share
2 answers

First, I will answer the question about how I do it . I am using MongoDB. I played around with the ideas you mentioned, but quickly crossed out solutions in memory (Memcached, Redis) for the same reason. My final solution ended up either in a relational database or in noSQL like MongoDB. Honestly, in my project scale, I did not think about reliable performance comparison between types of databases.

" " , "" "" , Mongo. , MySQL, json "-" flask, user = getUserFromMongo, dict Python, user['first_name']. :

Interaction with MongoDB (- ... SQL Rails)

MongoDB user

, , , Wit.ai context. , , context . , , . , , . , ( ), , , , context.

MongoDB , context, . , {name: yelp-search, stage:ask-for-user-location}, , . , context .

I Github, .

+5

mysql chatbot, NodeJS -. mysql .

, , if-else-if case switch (state), state.and facebook-id chatbot, - .

, {1,2,3}

1 , , . 1 , -1, 2.

, .

.

, .

+3

Source: https://habr.com/ru/post/1654418/


All Articles