Search code examples
python-3.xdialogflow-esdialogflow-es-fulfillment

How to set entity for planet's name - dialogflow


I am making a chatbot to ask basic questions about solar system. My main concern is how to set the entities for training phrases. example:

  1. What is the mass of moon?
  2. Moon's mass
  3. Tell me the mass of moon?

I have added an image below. My main concern is how to set the entites for mass and body. I have made a custom entity for mass as @body_mass and not sure how to do for planets/objects name. So that I can receive these values in backend. It is not recognizing in Diagnostic Info

image for what I did


Solution

  • The easiest way to do this would be by creating a @Property entity which can detect "What" a user would like to know about a planet, for instance:

    • Height
    • Mass
    • Age
    • Average pet per alien living on the planet
    • etc..

    Then you create another set of entities called @Planet with which you detect "Which" planet your user wants to know something about, for instance:

    • Earth
    • Mars
    • Saturn
    • etc..

    Then you could create one intent called "Get Planet Info intent" and put example phrases such as:

    • What is the @Property of @Planet
    • How @Property is @Planet

    By doing this you save yourself a lot of time because you don't have to create phrases for "What is the height of Earth" and "What is the height of Mars". You just capture a sentence for the property and the planet entity and it should work for every combination in your entities.

    You could even improve upon this by adding synonyms for the entities such as:

    • Height: Tall, Long
    • Age: Old, young
    • Mass: Big

    In your code all the information you have to check for is which @Property and which @Planet did Dialogflow detect, so it saves you from having to check for things such as Mass_Planet_A, Mass_Planet_B like you would now.