2

I'm using Recast.ai NLP Platform.I have create a simple bot on recast.ai console.Now,i want store my messages on MongoDb database.I have create a simple post type API for to save information on MongoDB. But i got stuck how to integrate or how to this from console.

My code for API :

app.post("/addname", (req, res) => {
  console.log("called");
    var myData = new User(req.body);
    myData.save()
        .then(item => {
            res.send("Name saved to database");
        })
        .catch(err => {
            res.status(400).send("Unable to save to database");
        });
});
plieb
  • 899
  • 1
  • 9
  • 23
QA Intern
  • 51
  • 1
  • 5

1 Answers1

0

The format that you are receiving from the Bot Builder is the JSON that you have on this page (Body configuration) https://cai.tools.sap/docs/concepts/code-and-webhook you should then store the nlp.source to get the message the user sent. In order to answer back the builder you need to answer with a JSON that is compliant with what the builder is expecting, the list of messages are listed here: https://cai.tools.sap/docs/concepts/structured-messages so you should probably send

res.send([{"type": "text", "content": "Name saved to database"}])
plieb
  • 899
  • 1
  • 9
  • 23