How to make api.ai agent learn something dynamically? - android

I am currently using api.ai , to create agent to perform specific tasks, but one question i don't have answer to is , can i make it learn something while chatting , mean that i speak my name is 'John Cena' and she should store it and then whenever i ask her again bot should answer me that. i know there is a way to do it by logging into api.ai web and manually add entries , but it will not help, is there any work around programmatically or automatically ? the file i've been using to practice is given in github . and here is working DEMO

You basically need for your bot to "learn" facts. There are many different ways to achieve this, but recently the most common way is to arrange knowledge into Semantic "Triples" and store the knowledge into a Graph repository (like Neo4j, Titan, Spark Graph, etc). In your example, "my name is John Cena" would translate into a Triple like ("anubava","Name","John Cena"). That way, the next time you are logged in as anubhava and ask "What is my name?", it would translate into a Graph search that will return "John Cena". A word of caution, achieving this is not trivial and would require some significant amount of fine tuning. For more info, you can check here and here.
Finally, most complete solutions (that I know of), are Server Side solutions. If you want for the whole knowledge base to reside in your mobile device, you could probably use the resources there as inspiration, and build your own Linked Data repository using an embedded database.
Hope this helps. Good luck.

To store and recall the user's name, you'll need to set up a webhook with some basic data persistence capabilities. Any database or key-value store would work fine.
Here's the breakdown:
Implement webhook fulfillment for the intent that captures the user's name. The webhook should store the name along with a unique, identifying ID that you should supply from your front-end in either the sessionId or as a context parameter in your call to /query.
Implement webhook fulfillment for the intent that reads the user's name. The webhook should look up the name by ID and return a response that tells the user their name.
The high-level docs for writing a fulfillment webhook are here:
https://docs.api.ai/docs/webhook

Related

Is it possible to add custom parameters to Firebase Dynamic Links?

So I'm developing a game for Android and I'm using Firebase for Authentication, to store user data, etc...
And now, I want to provide the user a way to share their score with their friends, so they can try to beat that score. I was thinking about sharing a dynamic link, and when the second user gets the link, the game would just start from that checkpoint.
But to do that, I would need to send a few data: the level Number, the first user's score, the first user's name.
I checked the documentation here and I saw that I can add some custom campaign parameters. But can I add those other parameters I need? If yes, How do I do it?
build Uri :
builder.scheme("https").authority("deepLink_from_firebase").appendQueryParameter("Param", Param_value).build();
and set that on setDeepLink()
To do this with Firebase, you would need to either encode all the custom data in the URL, or store it in your backend and use the URL as a key to retrieve the stored values. It's possible, but not as intuitive as you're hoping.
I would recommend investigating Branch.io (full disclosure: I am on the Branch team). The Branch service is free, does store an unlimited number of custom parameters with each link (exactly as you described), and interfaces perfectly with the other Firebase functions you are currently using. Branch links are used for this by many of the top apps in the world, including Airbnb, Pinterest, Tinder, and many others.

Android changeable database content via internet? (like news apps)

Hello I am beginner to Android development so I want to ask how to create dynamically changeable database (content) in Android?
I'm aware of sqlite shared preferences but how can I interact with them via internet and add new information like news apps? Could Parse help?
This is not a answer, but a comment rather, I don't have the 50 rep required to comment.
It all depends on the sort of functionality you want to achieve. I.e. do you want to be able to push new content to the device using the internet such as push notifications.
OR
Do you want the app to make a http connection to a api or your own news service on startup or on button press for example?
UPDATE
Ok you have decided you want something similar to option 2. I am not going to write code for you but I will point you in the right direction and if you get stuck, post a question.
Please take a look at:-
https://play.google.com/store/apps/details?id=com.rsoftware.news
If you have decided this is what you want or similar, this application uses an API calling infrastructure.
The API they use is called FAROO.
http://www.faroo.com/hp/api/api.html
I suggest reading the documentation, deciding if this is indeed what you want, then sign up and get a API key. Afterall it is free! enjoy coding, enjoy the errors that you will receive and persevere =).
How to make a API call
I suggest when using a API, test the queries through the browser first of all or use something like Runscope for testing their services. So first get their URL which is:-
http://www.faroo.com/api
If we were to go to this url we will get a 401 response code, which means unauthorised. This is because we haven't added our unique API key to the html query. So this url can take parameters. We simply append a ? to the end of the url and supply the parameters that FAROO offers such as:-
q which stands for query (what do you want FAROO to search for?)
start which is the number it should start from
length which is the number of results you want FAROO to return
key which is your unique to make the requests
etc etc...
So an example of a complete url would be:-
http://www.faroo.com/api?q=iphone&start=1&length=10&l=en&src=news&f=json
This url is for demonstration purposes... your own url will have a key=YourAPIKey
Also notice how the parameters are separated by & symbols i.e. q=iphone&start=1 so this part q we know stands for query which is iphone & start=1 & so on.
Hope this helps.

what kind of database solution suits my mobile apps

I am looking into options how to realize the following use case. A iOS/Android user is using my app which gets its table view data populated by a cloud database solution. The user must be able to send back information (e.g. name + date) which needs to be send back to the database and gets stored there in a/different table/s. Moreover, I would need the db-solution to run automated reports based on the information sent back by the users (e.g. in an excel file).
So far I only found ragic.com might suit my needs. But what other options are out there, which might not be as fancy looking but will get the job done. Thanks guys!
A WebService is considered best practice regarding these matters. Have a look at this guys tutorial:
http://android.programmerguru.com/android-webservice-example/

iOS/android hybrid app distribution/architecture model help or advice please

I am pretty new to the mobile end of development so forgive my naivety.
I would like to know if it's possible to have a structure/distribution model like the following:
Master App (has many "middle-man" instances)
!
!
Middle-man ( can customize data, look & feel, via web app and redistribute)
(has many end user viewers)
!
!
!
End User viewers( can download and install middle-man abc's app with middle-man's custom info)
Is this possible? I have searched around for quite a bit but perhaps I am searching the wrong terms?
I was thinking perhaps a couple options, let me know if it's sounds wrong.
Option 1 - Middle-man provides a special key code and end user types it in after installing the app to unlock it thereby storing the unique middle-man ID and displaying only their custom info. User only needs to enter code once. relation is stored in mysql perhaps??
Option 2 - create a build of the master template for each middle-man and provide the binary/install link along with a customized ini file to load correct ID? Or something to that effect.
Any better options out there? Something that allows for upgrades/new features to be passed down to all the instances easily.
Will this type of thing have any problems with the apple store if multiple middle men decide they want it on the app store?
Maybe I'm making it more complex than needed and could just use a simple "require login" for each end-user and the end user is tied to that middle man some how?
\The app could also be android app depending on middle-man requirements
Thanks in advance for any advice or links to helpful info.
If i had understood your question right, its a straight forward mobile app tied up with the backend.
User credentials for the middleman which shall associate with your
special key code.
Associate your actors(users) with roles and permission over accessing
content in the backend.
Your mobile app will pull the content only associated for the logged
in user.
Apart from this, you can store the content for offline etc.. Take phonegap approach and it pretty much does what you wanted to do.

How to best add a comment/rating system to an android app

I already published an android app where you can see a list of specific objects and detailed informations about them. The list changes every day but some of the objects can appear again.
The application is communicating with a PHP server over HTTP and periodically pulls the list of objects.
I now plan to extend the app to make it possible to rate the objects and add a comment similar to how it is done in the android market. I'd like to avoid forcing the user to sign up for an account for being able to comment.
I see two problems:
The comment-system could be abused by spammers
A comment could be added from another system
So my questions are:
How to protect the system from spam?
How to authenticate the application with the server?
How do I limit the number of comments to one per user and object?
What about the androids device id? Is it unique enough to use it as identifier for the user?
Which other problems do you see?
2020 Commenting/Rating/Reviews Options
Since Socialize is out, here are a few options you can explore:
Build your own comment/rating implementation. Personally I love reddit and how it handles nested comments and ratings. Here's a library I found that implements it beautifully. Please note you'll need to tie this with a cloud-database. This is based on groupie. Article & implementation. Many ways to do this - https://stackoverflow.com/a/59472206/668240
Disqus - SDK's coming soon to iOS and Android.
BazaarVoice - commercial
Social Networks SDKs like Facebook, Twitter, etc. Personally I dislike this as we'll need to authenticate users with respective networks to use the APIs. It's like we are shipping off users of our apps to social networks. If you don't have a problem with that - then it might be for you
Legacy Option in 2014:
You can try out Socialize SDK which is open-source and a really good SDK for the rating and commenting you are looking for. It already has a well-functioning Commenting system built-in along with a 'like/love' facility and sharing to FB and Twitter. Each 'entity' (object in your case) can have metadata associated with it. So all you have to do is construct/use a rating widget, then send that rating with the entity attached to your object. To display your rating/comment is as simple as retrieving them from Socialize.
Each object (element from your app) should be associated with an entity which has a unique key in the form of a URL - sort of like a primary key to recognize your items. This entity can have meta-data - any data that you can insert on behalf of your object. Once you do that, you can retrieve that metadata any time you want.
I've been using Socialize for around a year now. They've matured over this period and are always aspiring to be the best at what they do.
Look at the Socialize Bar at the bottom. Its can be customized to your needs.
What's more - Socialize is free.
As for your questions:
There is comment moderation built into the Socialize Web Component
where you can filter out anything you feel is out of place.
Socialize allows you to authenticate through Facebook and Twitter.
Limiting to one comment per user can be achieved by using their User
and Comments API.
Socialize has both Anonymous authentication as well as Social A/c
authentication. I believe you can remove anonymous auth. So that
ensure that every user is authenticated before rating/commenting.
For authentication, you could use OpenID like StackOverflow does or Facebook authentication. Once you have them authentication, it shoud be easy to limit the number of comments to one per user per object. As far as spam, you could follow StackOverflow's model and allow users to vote comments up or down or flag as spam. Perhaps users with comments that have been voted up would have more power and be able to flag comments as spam.
You'll need some sort of rate limiting. I've used this one in this example before.
So you need a table with the user's ID and how many api calls they have left, and then when their last api call was. Then use the algorithm to update the values in the table every time a method is called.
Read through this, I think it should be possible to create an UUID for every case:
http://android-developers.blogspot.de/2011/03/identifying-app-installations.html
And then keep a hidden api key which is hard coded, or at least get's everytime calculated the same or in enigma style influenced by the time it is used. But you will be never be sure, that it won't be find out by crackers/hackers and maybe abused, you will always have this Problem.
Authenticate with the UUID of the user + api-key.

Categories

Resources