简体   繁体   English

Dialogflow 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.我是 Dialogflow CX 的新手,在阅读了其 node.js 文档(我是一名初级开发人员)之后,我仍在努力解决以下问题。

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?”问题:我需要我的聊天机器人来接收问题“您是否有黑色的丰田卡罗拉(汽车),2017 年或更新的里程少于 20,000 英里,售价低于 15?000 美元?”

CONTEXT: I have a database with all car makes, models, years, versions, mileage, colors and prices available.上下文:我有一个包含所有汽车品牌、型号、年份、版本、里程、colors 和可用价格的数据库。 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.问:如果您能帮助我启动 Dialogflow CX 机器人,我将非常感激,将所有汽车品牌、型号、年份、版本、colors 和价格作为实体加载到其中,然后给出用户需要的答案。

I've checked the GitHub quickstarts and read the documentation multiple times but am still very confused.我检查了 GitHub 快速入门并多次阅读文档,但仍然很困惑。

It looks like you have a few different issues with some of the Dialogflow CX basics.看起来您对一些 Dialogflow CX 基础知识有一些不同的问题。 Let's try to clear them up.让我们尝试清除它们。

How do I initiate the Dialogflow CX bot?如何启动 Dialogflow CX 机器人?

It isn't clear what you mean, exactly, from this.不清楚你的意思,确切地说,从这里。

Dialogflow CX, itself, isn't a bot client. Dialogflow CX 本身并不是机器人客户端。 Instead, it providesintegrations 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.这可能包括电话集成、基于 Web 的聊天系统和 API,以便您可以与 Slack 等其他客户端集成。

Your Dialogflow CX agent, itself, is setup using Google's Cloud services, and can support one or more of these integrations.您的 Dialogflow CX 代理本身是使用 Google 的云服务设置的,并且可以支持这些集成中的一个或多个。

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.它可能应该有别名,以便人们可以说“Ford Explorer”或只是“Explorer”并让它解析为相同的类型。

If you really wanted to use an API to do this, you could use EntityType.create to do so.如果您真的想使用 API 来执行此操作,您可以使用EntityType.create来执行此操作。 That points to the REST documentation, but based on the language you want to use, there may be a library able to handle it.这指向 REST 文档,但根据您要使用的语言,可能有一个库能够处理它。

Some of the other types, however, can be handled with system entity types such as @sys.color or a numeric type.但是,可以使用系统实体类型(例如@sys.color或数字类型)来处理其他一些类型。 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.您需要将此数据库调用作为您为实现业务逻辑而创建的webhook的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM