Search code examples
node.jsgoogle-api-nodejs-clientdialogflow-cx

Dialogflow CX - Add bulk entities and query them


I’m new to Dialogflow CX and after reading its node.js documentation (I’m a jr Dev) I’m still struggling to get the problem below solved.

PROBLEM: I need my chatbot to receive the question “do you have Toyota Corollas (cars!) in black with less than 20,000 miles, 2017 or newer and cheaper than $15,000 for sale?”

CONTEXT: I have a database with all car makes, models, years, versions, mileage, colors and prices available. The problem is that I can’t (and sorry for how silly this looks) even initiate the bot and I know that after initiating it I would need to create a zillion entities through code (can’t do it manually) so the bot would be able to read all car parameters of the user’s question. Then after reading those parameters (entities) the bot should query my database to check availability of those particular Corollas and then give a proper answer.

ASK: I would be very grateful if you could please help me initiate the Dialogflow CX bot, load all car makes, models, years, versions, colors and prices into it AS ENTITIES and then give the answer that the user needs.

I’ve checked the GitHub quickstarts and read the documentation multiple times but am still very confused.


Solution

  • It looks like you have a few different issues with some of the Dialogflow CX basics. Let's try to clear them up.

    How do I initiate the Dialogflow CX bot?

    It isn't clear what you mean, exactly, from this.

    Dialogflow CX, itself, isn't a bot client. Instead, it provides integrations with various ways to communicate with your agent. This may include telephone integrations, web-based chat systems, and an API so you can integrate with other clients such as Slack.

    Your Dialogflow CX agent, itself, is setup using Google's Cloud services, and can support one or more of these integrations.

    How do I create a zillion entities through code?

    It isn't clear why you need to create a zillion of them, nevermind through code itself.

    You likely will want to create a custom entity type for the make/model combination. And it should probably have aliases, so that people could say "Ford Explorer" or just "Explorer" and have it resolve to the same type.

    If you really wanted to use an API to do this, you could use EntityType.create to do so. That points to the REST documentation, but based on the language you want to use, there may be a library able to handle it.

    Some of the other types, however, can be handled with system entity types such as @sys.color or a numeric type. There's no reason for you to create those.

    But what happens if someone asks for a combination that isn't valid?

    Then you'll need to tell them it isn't valid. Just like if someone was talking to you in person and asked for something that didn't make sense.

    How will it check the database for a good response?

    You'll need to make this database call as part of a webhook that you create to implement the business logic.