as you see in the tutorial , you define actions in wit.ai, these actions can include variables that can be sent as a response to users. Thus, you must query the database in the actions that you defined, if you did not define them, then do it because you can make your own logic there. Also, keep in mind that you can process unsynchronized petitions in your database, then you must implement a block mechanism to return a context in each action immediately after you make a request.
I know that you want to make an implementation in python, but I already have an implementation in node.js, so here is my sample code.
getFullName({sessionId, context, entities}) {
let session;
let fbid = sessionId.split("-")[0];
return fbTypingOn(fbid)
.then(() => {
return model.getSesion(fbid);
})
.then(sesion => {
session = sesion;
return callFbUserAPI(session);
})
.then(first_name => {
session.context.fullNameGreeting = utilsBot.buildGreeting(session);
return model.setSesion(session);
})
.then( sesion => {
return session.context;
})
.catch( error => {
console.log("Error in getFullName " + error);
session.context.fullNameGreeting = "Hola";
return context;
});
}
, , , - , . , -, python 2.