I am currently working on a project that involves creating a "chatbot". It's not going to be any kind of "AI", deep learning or anything fancy like that. It's going to be a "menu/button based chatbot" (As they call it around on the web). I have no idea how to tackle this kind of functionality. It's going to be inside an app, I will be using Ionic and the "database" will be stored on firebase as a JSON (however I am open to use something else if its easier).
When communicating with the chatbot, the user will only be able to use closed answer, mainly 1,2,3 or 4 responses. Each responses will lead to the next question and so on.
We then have to create a structure of all the different possibilities.
Let's say the chatbot starts by asking "What do you want to eat for dinner ? " and the user has 2 choices: pasta, pizza. Then, depending of the user's anwser, we then display the next question. So the user has a very limited range of answer but we need to catter for every path.
What I am thinking so far is having a JSON config with blocks like this:
{
address: 0001,
type: 1, // The type will probably help to identify the kind of block
question: 'What do you want to eat for dinner?',
responses : [{
title: "pasta",
link: 0002,
}, {
title: "pizza",
link: 0003,
}
},
{
address: 0002,
type: 1,
question: 'Great you want to eat some pasta, what else?',
responses : [{
title: "Cheese",
link: 0004,
}, {
title: "Cake",
link: 0005,
}
}, etc.
So when the user clicks on "pasta", I should display the next block (which is the one with the address 0002). I could have different block types, ones that will display text question, others that will just display a video in the chat or any other kind. (so blocks might be more complex with video url, images etc.)
I am thinking of creating a very basic tool that will helps to create all the different blocks that will then generate the massive JSON config.
But this have two downsides :
-> I need to define one block for each interactions. (This will lead in having hundreds of blocks if the chatbot becomes big)
-> Let's say I want to offer something a bit more personalised and I need to use some data stored outside of the chatbot (on the user profile for example).
Let's say the user has specified if he is or is not allergic to cheese.
pizza->cheese (he is allergic)-> go to 'you should avoid cheese'
pizza->cheese (he is not allergic)-> go to 'great, what do you want for dessert?'
But in my model, cheese always go to address 0004, so this is not going to work. I need the block to have some "rules" about where to go next depending of some variables, but this seems to be tricky...
I am open to use any kind of API, I've seen tons but not something I can easily integrate in Ionic. I want to have some control on the design and I would like to avoid being dependent of an external solution, but still I am curious if anything can fit my needs.
I would take a look at Watson Assistant and look at the different kinds of responses you can implement.
The above image is what adding an option response would look like similar to the example JSON you posted.
It might be too much in some cases, but having a framework to handle some of the dialog node traversals is quite handy.
Related
I have a problem with HowTo objects in schema.org data format (JSON-LD to be precise). I was trying to google something, but HowTo name is rather problematic.
I have two instructions on the same webpage. I'd like to add two HowTo objects so that they look pretty in google. I'm using JSON-LD to put the objects on the page. I was trying to simply put two HowTo objects:
{
"#context": "http://schema.org",
"#graph": [
{
"#type": "HowTo",
...
},
{
"#type": "HowTo",
...
}
]
}
but Google's Rich Result Test (https://search.google.com/test/rich-results) says that I can put only one HowTo object on a page. I'm not surprised as that's what the google documentation says: https://developers.google.com/search/docs/data-types/how-to#how-to (if the link doesn't lead to the correct section: Contents -> Structured data type definitions -> HowTo)
You can check it for yourself and experiment with an example HTML I've made using two examples from google documentation (I'm not putting it directly on Stack as it's a little long): https://gist.github.com/Hoxmot/2eec6a39bcd9fe2b46a8eaadea9afe27
The problem is that it also says that: https://developers.google.com/search/docs/data-types/how-to#how-to-section (Contents -> Structured data type definitions -> HowToSection)
For listing multiple ways to complete a task, use multiple HowTo objects.
Is there a way to have two (or more) HowTo instructions on one page? I was also trying to use multiple HowToSections but that doesn't work as desired - it's listed as one solution.
I have this piece of code in JSON editor of Watson:
"context": {
"array": "<? entities['spare_part'].![literal] ?>",
"array_size": "<?$array.size() ?>"
When the input of the user, for example, is "Hello, I need a valve, and the part number of the valve is 1234", the size of the array ends up being 2 since the user mentions the word "valve" twice in his input. Some nodes are being executed depending on size of the array. For instance if the size of the array is 1, some nodes will be ignored because they are only executed only if the size of the array is 2.
I want the array to store only the inputs with different values, which is basically I don`t want the array to store the values of the same type, in my case 2 valves. If it is possible somehow please show me a way.
All that can be done, but the best approach depends on the overall system architecture. Remember that Watson Assistant is a conversation service, not a data processing platform...
You can process JSON in either Watson Assistant directly using the built-in methods and SpEL, see these links to get started:
- https://console.bluemix.net/docs/services/conversation/expression-language.html#expressions-for-accessing-objects
- http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html
- https://console.bluemix.net/docs/services/conversation/dialog-methods.html#expression-language-methods
That would require some coding within the dialog nodes. It could be ok. What I would recommend is to either process in your app that drives the dialog (you need that app anyway) or to code up small server actions to transform data.
If it is the word you are looking for, you can use contextual entities to train for this.
As an example I created the following intent (along with general intents from catalog).
For each example I highlighted the "valve" word that is the one I am interested in, and added to the entity.
Now when I test it I get the following.
All this was done in a couple of minutes. For production level you may want to add more examples, or think about how you want to annotate.
I've been implementing a RESTful web service which has these operations:
List articles:
GET /articles
Delete articles (which should remove only selected articles to a trash bin):
DELETE /articles
List articles in the trash bin:
GET /trash/articles
I have to implement an operation for restoring "articles" from "/trash/articles" back to "/articles".
And here is the question. Ho do you usually do it? What url do I have to use?
I came up to the 2 ways of doing it. The first is:
DELETE /trash/articles
But it feels strange and a user can read it like "delete it permanently, don't restore".
And the second way is
PUT /trash/articles
Which is more odd and a user will be confused what this operation does.
I'm new to REST, so please advice how you do it normally. I tried to search in google but I don't know how to ask it right, so I didn't get something useful.
Another option could be to use "query params" to define a "complementary action/verb" to cover this "special condition" you have (given that this is not very easily covered by the HTTP verbs). This then could be done for example by:
PUT /trash/articles?restore=true
This would make the URI path still complaint with REST guideline (referring to a resource, and not encoding "actions" - like "restore") and would shift the "extra semantics" of what you want to do (which is a very special situation) to the "query parameter". "Query params" are very commonly used for "filtering" resources in REST, not so much for this kind of situation... but maybe this is a reasonable assumption given your requirements.
I would recommend using
PUT /restore/articles
or
PUT /restore/trash/articles
Late answer but, in my opinion, the best way is to change the resource itself.
For instance:
<article is_in_trash="true">
<title>come title</title>
<body>the article body</body>
<date>1990-01-01</date>
</article>
So, in order to remove the article from Trash, you would simple use PUT an updated version of the article, where is_in_trash="false".
I am working on migrating posts from the RightNow infrastructure to another service called ZenDesk. I noticed that whenever users added files or even URL links, when I pull the xml data from RightNow it gives me a lot of weird codes like this:
{s:3:""url"";s:45:""/files/56f5be6c1/MUG_presso.pdf"";s:4:""name"";s:27:""MUG presso.pdf"";s:4:""size"";s:5:""2.1MB"";}
It wasn't too hard to write something that parses them and makes normal urls and links, but I was just wondering if this is something specific to the RightNow service, or if it is a tag system that is used. I tried googling for this but am getting some weird results so, thought stack overflow might have someone who has run into this one.
So, anyone know what these {s ;} tags are called and if there are any particular tools to use to read them?
Any answers appreciated!
This resembles partial PHP serialized data, as returned by the serialize() call. It looks like someone may have turned each " into "", which could prevent it from parsing properly. If it's wrapped with text like this before the {s: section, it's almost definitely PHP.
a:6:{i:1;a:10:{s:
These letters/numbers mean things like "an array with six elements follows", "a string of length 20 follows", etc.
You can use any PHP instance with unserialize() to handle the data. If those double-quotes are indeed returned by the API, you might need to replace :"" and ""; with " before parsing.
Parsing modules exist for other languages like Python. You can find more information in this answer.
I come from heavy web application dev background, and having some problems representing my related data structures the right way in iPhone dev (the 'Model' part of MVC).
Lets say I have a data structure which is best represented via JSON like this:
{
"Beethoven": {
"description": "Another great composer",
"pictures": [
"pic1",
"pic2",
"pic3"
]
},
"Mozart": {
"description": "Great Austrian composer",
"pictures": [
"pic1",
"pic2",
"pic3"
]
}
}
This works great in Python/Django, but what would be the right approach for iPhone dev?
Eventually this would be stored in a property list (as the data won't too big/complex).
Should I create Composer class to represent top level objects? or some other way?
You propably want to use CoreData. This framework allows you to create an abstract model of your data, just like for databases, and to use it in your app without writing a single line of code. It also provides independence of your persistent data storage, so you can switch between different types of storage (SQLite, XML...) easily. I quite liked this tutorial but you might also want to check out the official documentation.