1

I would like to store an entire sentence an user said and store it.
enter image description here


This his how I did but I can't get the sentence from A to Z an an whole entity, just few parts knows as "number", "location", ....

merge(request) {
    return new Promise(function(resolve, reject) {
        var entities = request.entities;
        var context = request.context;
        var message = request.message;
        var sessionId = request.sessionId;

        var intent = firstEntityValue(entities, 'intent');

        if (intent == "write_free_text") {
            context.free_text = request["text"];
        }
        if (intent == "choose_city") {
            var city = firstEntityValue(entities, 'location');
            context.city = city;
        }
        return resolve(context);
    });
}

How can I do that and store the whole sentence with merge function ? Thank you

Pablo DelaNoche
  • 677
  • 1
  • 9
  • 28
  • Try to get the `message` in your `merge` method. I think for this case you don't need use intent – Adriano Godoy Jan 13 '17 at 18:08
  • I tried "wit/message_body", "wit/phrase_to_translate" and others but it always cut my sentence or cause bad behaviors ! I can't get back all the sentence from A to Z without wit interpretations !! Very annoying, any help will be appreciate. Thanks – Pablo DelaNoche Jan 16 '17 at 15:50

3 Answers3

0

if you want to get the whole phrase, use the wit/phrase_to_translate built-in entity

0

If you want the whole sentence, maybe you don't needs a entity, just get the message sent:

// Merge action
function merge(request) {
  context.freetext = request["text"];
  return context;
}

Bot: https://wit.ai/Godoy/bottest/stories/4da2840f-513e-42ed-a494-c5516c07242e

Fiddle with code: https://wit-ai.github.io/witty-fiddle/?id=e4c16a624c87d37f9c0c29d8299ca5fc

Adriano Godoy
  • 1,488
  • 1
  • 11
  • 21
  • Thank you for your answer. I edited my initial question. I tried without entity and I did like you said. But there are a lot of troubles ! Here is what I get back when I write my free text : `{"distance":[{"confidence":1,"type":"value","value":123123}],"intent":[{"confidence":0.8779698641320263,"value":"choisir une date"}]}`. So, the "write_free_text" is not recognized and I can't get "request["text"]" back. – Pablo DelaNoche Jan 16 '17 at 20:16
  • 1
    Ok, so I tried and I succeed like you said ! But with this "method" Wit failed to recognize the intent "write_free_text" so I had to do like that : `if(!intent) { context.text = request["text"]; }` . Thank you again ! I accepted your answer – Pablo DelaNoche Jan 16 '17 at 20:33
0

a snapshot of the uunderstanding tab

you just have to train the bot, once or twice. It will pick up all the free text later.