Dialogflow CX - Add bulk entities and query them - node.js

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.

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.

Related

How should I build this app over communcation apps?

These days I am finding myself in the position of having to implement for one of my college courses a system that should act as a giant wrapper over many communications apps like Gmail , Facebook Messenger maybe even WhatsApp .To put it simply you should have a giant web interface where you can authorize Gmail , Messenger and use them at once when required. I am thinking of going with an REST API to manage the user's services authorized by OAuth2.Also I am thinking of using Node.JS and Express.js in the backend and React.js in the frontend. I found some sweet libraries in npm that should take care of interacting with the involved APIs(https://www.npmjs.com/package/node-gmail-api this one for instance), but I am also doubtful about this approach , for example I have no idea how to keep the use notified about its incoming mails or messages for example . I am in dire need of some expertise since I forgot to mention but I am quite the newbie in this field. To sum it up for once my question is how would you implement such an infrastructure ? Is it my approach viable or I am bound to hit some really hard to overcome obstacles?
As a college exercise, it would be a really fun experiment, so it definitely worth the time you want to put into it. However, once you want to add more features, the complexity will go up pretty fast.
Here are a couple of ideas you can think of:
It's pretty clear that your system can't do more things than the capabilities exposed by the APIs of communication apps (e.g. you can't have notifications in gmail if the API doesn't have this capability).
For that reason, you should carefully study the APIs and what functionalities they expose. They have public docs that you can check out: (Gmail API, Facebook Messanger API)
Some of the apps you want to communicate with may not have an official API (e.g. WhatsApp) - those kinds of details you definitely want to know from the start.
Based on the analysis of those APIs, you should lay out a list of requirements for your system, which can be extracted from all the APIs, for example: message notifications, file transfers, user profiles, etc.
In this way, you know exactly what capabilities your system should have, and you don't end up implementing a feature that is available only in 1 API out of 4.
Also, it would be a bit challenging to design your system from a user perspective, because the apps have different usage patterns - chat apps, where messages are coming in real-time, vs email, which is not real-time communication. That's just a detail anyway, the gist of your project is to play with those APIs.
Also, it may worth checking out the Gateway Aggergation Pattern, which is related to this project - you may want the user to send a message to multiple apps, by using a single request to your service.

How to make a chatbot only for searching the excel

I want to make the simplest chatbot for searching the information much easier.
For example, if I ask John’s major, my chatbot will answer that it is Computer science. So simple.
But I found that if I want to make a chatbot which is answering based on database should through webhook thing, and It doesn’t sound easy for me.
Is there any other (easy) way to make chatbot based on excel data or send a query... or whatever databases..
I want to make this on dialogflow!
+If i use chatscript, webhook is not necessary?
You need a webhook to connect to your application which can do what you need.
You have 2 options in DialogFlow:
Webhook URL: to invoke your custom application (here you have all the flexibility you need: access Excel, compute a response, etc..)
Inline Editor: create a Cloud Function on Google Firebase (I have no experience but I expect you can do almost anything you need - check pricing as it is a cloud service)
Setup #1 is not difficult, the harder part is to manage/access the XLS file programmatically.
Best of luck,
Beppe

I want to use Alexa API to read grocery list (for display in a web app.) Must I write a "skill"?

First my apologies if this is a dumb question, or has been asked before. I've been searching for a couple of days and can't find an answer. This usually means I'm asking a dumb question. ;-)
I have a rPi and touchscreen in my kitchen; it displays helpful things like appointments for next 7 days, weather next 7 days, news headlines, etc. It's a web app I wrote in Angular 7, and it queries a NodeJS v8 backend which I also wrote. This was a hobby project to learn Angular and Node.
The Node app performs all interactions with the outside world, using Google's Calendar API to get appointments, Yahoo Weather API, newsapi.org. All of these integrations followed the same pattern -- obtain some apikey token, and use that when invoking some API method to get the requested data in a JSON wad.
Now, I would like to also get the grocery list from my Echo. After reviewing Amazon's Alexa API documentation, it doesn't appear that I can do this the same way as the previous three integrations I did. Must I really write a "skill" for this, though I never intend to invoke it on the Echo?
And if so, could you point to a decent sample? None of the samples provided by Amazon utilize the Lists API.
Yes, you must create a skill in order to receive access_token. And then - Out of Session Interaction feature might be useful.

Add more small talk options into Dialogflow

I am utilising the small talk options within the chatbot that I currently use, however, I have noticed a couple of common questions which seem to be asked which fit into small talk, such as "What is your name?" and "What does you name mean?".
Is there any way in which I can add to the list of small talk questions? If not, how can I add these questions in with their responses? My issue is that I believe that you shall need a new intent for every question that gets asked? Any help would be appreciated.
Using a new intent for every question asked (or at least different versions of the same question with one answer) is the standard Dialogflow design and isn't really a problem.
The small talk functionality is just a big list of questions and answers in separate intents - you can see by looking at the pre built small talk agent through Prebuilt Agents -> Small Talk -> Import.
Therefore I would suggest to simply do it this way.
Initially, small-talk option had this issue which you specified here where users were not able to add more phrases to existing questions or add more questions.
To solve this issue, DialogFlow has introduced Small Talk Pre-built Agent.
There are approx 86 pre-built intents in the small-talk agent.
You can add/modify the phrases in those intents,
You can add/delete intents
You can modify the responses of these intents
To use small-talk agent, go to pre-built agents option in left menu, go to Small Talk agent, then import it.
Hope it helps.
I will suggest to use QnA maker service to achieve the functionality. Basically you have to create a QnA maker service and have to integrate to Bot. It will resolve your query. Please let us know if you need more information .
Regards,
Tharak

Expression Engine: When to use channels and when not to use them?

I am still a relative newcomer to Expression Engine as a developer and a user. I am faced with the problem that a lot of my knowledge is being passed to me by users who have found ways to accomplish tasks traditionally undertaken by developers (eg product libraries) by using the channels system.
What I wondered was what people's views are on when it is best to advise a client to use this and when not to.
Let me use an example, a client wants a system which had venues where events could take place. The previous developer had chosen to use the membership system for the venues and the channels system for the events and write some custom code to attempt to knit the two together, specifically because there are not enough hooks to accomplish some background automated tasks like looking up the long/lat of the address of a venue when it is created or updated.
I am picking up after someone else's work largely but its not their fault, it was the information they were given as they were also new to the system.
In any other project this would be a master-detail type setup, events belong to venues, i'd probably write 2 custom tables, editors in the admin area via modules and then use regular custom code in the pages to display and act upon the info - this way, I could control what's happening when a user hits submit.
However, the instigating party is a veteran user of Expression Engine and instructed the previous developer in the manner of "oh, just put it all in the channels and then there's this tag and that tag and so on".
So, am I missing the point or am I right that this does not fit the channels system and when should you use channels and when not?
Thanks friends.
This question is very hypothetical and every developer will give you a different answer as it all depends on the requirement and how that EE developer rolls.
Fundamentally ExpressionEngine allows you to approach builds in many ways, none are right and wrong, albeit some are easier, some harder, others just plain daft.
Basically Channels are groups of data "entries" - these can be anything. Using your example, venues could be one channel with fields created relevant to the subject (e.g. location, size, price, etc). And another channel for events with different fields (e.g. date, type, location).
Mostly anything can be slotted into a channel. But member details are best held within the native member functionality (although there is a commercial add-on that holds member data in a channel).
You reference the previous developers approach - this could be because they used a third-party add-on that required the data to be held separately to channels, or a lack of understanding on best approach. Or just because the developer decided to approach it that way! I suspect the last developer then associated a member (venue) to an entry (event) to link the event to the venue. Basic EE functionality allows for related entries which allows you to associate 1 entry with another (e.g. Event -> Venue), or using the excellent Playa add-on, so this approach is really not necessary.
Personally I would always store the data in channels, and people/members in the native membership functionality (e.g. admin, visitors to the site, customers, etc). I'd only build an add-on (utilising it's own tables/data) to store additional information if it was way outside what EE could store.
To answer your practical question (it's stretching the scope of what Stack Overflow questions are supposed be honestly): you should use a channel for Venues and channel for Events, and the Venue field in the Event entry is a "Related Entries" fieldtype linked to the Venues channel. That's the "standard" EE way, and the most similar to a traditional database schema.

Resources