I'm trying to create this:
It goes through your friends, finds the ones with new posts and retrieves them. What's the logic that would go behind something like this? What should I be trying to do?
I know two popular way to deliver news to receivers.
First way
Receiver asking for news from friends with a certain frequency. In this case server works as mediator for senders and receivers. Client application asking for news from paticular friend application. For this architecture typically used Mediator pattern:
Second way
Source of news sends this to server. Server works as observer and sends news directly to receivers with online state. Otherwise, server collects news for particular user (client application) in queue. For this behaviour typically used Observer pattern:
For more information about architecture templates see source PDF
Related
I have my application running on AWS on tomcat instance with Java code with mongodb database.
I now need to integrate this with Facebook messenger ChatBot and wit.ai.
I am really struggling to get started, some sample code i have found but in different languages.
Can i run this and integrate with my portal running on Tomcat. it should call both Facebook messenger and wit api.
I need to get high level idea as to how to proceed.
To connect wit.ai to your facebook page, you just need to create an accound with wit.ai, and then create a new application (or use the default starting one).
Then you can go to the settings of the app, and you will se the Server Access Token code.
You need to paste that server access code in the field "Integrated NLP", that you will find in your Facebook for Developers account, then access the application that you want to use NLP, in the setting for Messenger. For that you must have the messenger app already created and configured with it's webhook wich I guess you have.
Once that's done, the Natural Language Processing (NLP) will be sent to your server automatically as another field in the message. And it's preety simple to understand and train from wit.ai
The messages of the user will be analyzed by wit.ai, and if it finds any entity of the default ones or one defined by you training the bot from wit.ai, will send it to messenger, and this one will insert the NLP in the message.
So you will recive a normal JSON message from messenger, with an extra field called NLP that will contain something like the following example:
"text":"reservar una pista","nlp":{"entities":{"tipo_cita":[{"confidence":0.98398202482107,"value":"pista","_entity":"tipo_cita"}]},"detected_locales":[{"locale":"es_XX","confidence":0.9935}]}}}]
My chatbot is in spanish, but there's an example of how you can see the NLP in the JSON message.
I introduced the text: "reservar una pista"
And it recognized the value: "pista" with a confidence of 0.9839. Wit also detected the language "es_XX" that's spanish with a confidence of 0.9935.
First of all think about what your bot should do. What functionality will it provide, which questions will be asked by users and how you would like to respond to that.
If you have a general idea about your problem space you can start thinking about the technical challenges.
Be aware that both the Messenger Platform and wit.ai are completely independent products and they provide an HTTP interface to their service. That means you can use any language you like to interact with these platforms. Your application acts as the middleman to these services.
Start off establishing an integration with the Messenger Platform so you that you are able to both receive and send messages.
For that you have to create a Facebook page which acts as the identity of your product. Users will find you in Messenger by your pages' name. You also need to create a Facebook app where you subscribe to your page and specify the webhook settings so that messages are relayed to your own backend service.
The documentation for this is really good and I advise you read it carefully. You can find it here.
After going through the docs you will have a good understanding of what you can do with the Messenger Platform and which types of messages you can send and receive.
Once your able to send and receive messages you can start to extract some sense out of them. For this you can use wit.ai, but there are also other services you might consider. E.g Google just released their own NLP platform which provides similar features. See here
Also there is api.ai
In general you have to send received messages to the service of your liking and get back structured information about what the intent of the user is and what values where extracted. With that information you can act accordingly.
If you want to stick with wit.ai go through their Getting Started guide and recipes section. That enabled me to use their platform.
I hope this gives you a general idea about how an integration could work. This is fairly high-level and much of the details (especially on the NLP side) depend on your specific use cases.
You can use a sample nodejs implementation of witai and facebook messenger from their official repo. First of all, you have to train the model of witai to understand expressions and extract entities. Then set up the messenger bot on fb and attach it to some fb page. Once you are able to get the messages from the webhook callback send them to the witai API. You will also have to define actions in your code for the witai to execute actions defined in the model.
I am working on website to upload movie and watch with others. Also, I am working on cloud.
Until know I did how upload movie and stream it on website but I`m thinking if end-user want to watch movie in synchronizing way, how could I do that?
I mean, If I want watch movie with my friend, in two different location and both of us can play movie or pause it at a same time...
Do you have any idea?
Let's assume the client is a webbrowser.
You'd have to keep both (or all) clients in sync.
You cannot really initiate communication from the server, so your clients need to periodically "ask" the the server (maybe using AJAX) something similar to "should the movie be playing right now?" and take the accoring action on the client (which are using JavaScript perhaps?).
You could put this as a property in an object on the server to which all clients have access. You'd need to figure out how to share that object amongst all client sessions.
I am implementing a small social networking website, and I am trying to implement notifications.
Notifications have the following requirements
All users will receive notifications whenever users they follow do
certain events (like a post, create a post,leave a comment, etc...
When a set of notifications for a user is unread, just like on facebook, the user will
continue to see a read notification icon on their navbar.
Problem : I am taking an example to describe my problem for better understanding for everyone.
Suppose there are two users A and B. A & B are friends and A post something, suddenly B like the post of A then A should have to receive the notification immediately.
So how can i achieve this immediately receiving of notification process?
Should i send a call to server on each millisecond to check whether there is any unread notification is available for A user ? In this case thousand millions of call creating for multiple user. It is feasible solution ?
(I think it create unnecessary load on my website. As i think facebook and stackoverflow do not use this way).
Provide me a suitable solution just like fb and other webiste using.
Technology Using in my project: Java and MYSQL
You should use JavaScript (client side) along with Java - MySql (Server side), and more specifically Ajax. You will need some time to understand the concept and the usage but it does exactly what you want.
To give more details, what you need is to create a partial view where the notifications will appear, and update this partial view async (with AJAX).
Dont reinvent the wheel.
Use ajax call to server at each interval and check your server and update nav acc.
1.So how can i achieve this immediately receiving of notification process?
2) Should i send a call to server on each millisecond to check whether there is any unread notification is available for A user ?
Your above both questions answers solve through GWTEventService implementation.
Through it you can write code that will avoid client to server round trip.
GWTEventService is an event-based client-server communication framework. It uses GWT-RPC and the Comet / server-push technique. The client side offers a high-level API with opportunities to register listeners to the server like to a GUI component. Events can be added to a context/domain on the server side and the listeners on the client side get informed about the incoming events. The server side is completely independent of the client implementation and is highly configurable. Domains can be defined to decide which events are important for the different contexts.
Refer link: https://code.google.com/p/gwteventservice/
I'm new in development of applications for Android so I'm asking those questions for know which is better way to make RSS reader app. I have a server that downloads and stores on database news from Yahoo. On this database are stored title, content, publication date and link of news. Than I'm making HTTP POST to server to download news to Android. Data from server to android are passed in Json.
Can people, who already had developed an application like this, answer my questions?
Should I pass all list of news in one response to POST or it's better to make it's better to make several POSTs to get the same list? I'm asking this question because response from server may be too big and I don't know which is a better way to transmit it.
Comment system is the feature of my app. So need I to create a authentication system or it's possible to make it basing on ID of phone?
Another thing I need to do is to alert user when new news has appeared on server. I don't have idea how to do it with HTTP POST? Need I send to server list of nees that I have on Android?
Thank you for attention.
Here are the answers for your respective wuestions
1) This depends more on kind of UI you chose for your Android application. In my perspective you should go for multi-page (like prev-next links on bottom of screen) UI for your reader. And you should cache the results of previous page as well as next page in you app (so this also means to fetch selective results only) so that when user clicks on next/prev button the responsiveness of you application is good.
2) Ideally you app should ask for show a pop-up dialog asking to authenticate for commenting. You should use something like http://developer.android.com/reference/android/accounts/AccountManager.html to store these credentials so that from next time you do not ask the credentials again once authentication is successful.
3) In this case you should look at http://code.google.com/android/c2dm/
Polling is surely not the way to go :)
See it depends on how big your file is and more importantly how quickly do you need it.
More requests will certainly increase the latency. What generally you should go for is for one request.
But it again depends, I was once working on an android app and had the same problem. But in my case I split it into 2 requests. One so that I get initial data quickly and can disply to the user. Later with another request I can get the remaining data. So see wh1t suits you more.
Also how many requests will you have to make on an average in an hour. More polling will surely eat your battery a lot. If pushing can help you, try seeing if google's C2DM can be of any help.
For Rss parser ibm has an excellent link at http://www.ibm.com/developerworks/xml/tutorials/x-androidrss/index.html
POST vs GET - POST is meant to change state of server, whole GET is for reading results -
you should use GET to retrieve news, and POST to post comments
Use timastamp to retrieve news from some moment, update timestamp on the device
with latest received news timestamp - this will save traffic for your users and your server. First update will get everything ( you may also put a limiton amopunt of news retrieved in single batch )
everything based on something present on phone is not strong. however, you can use some kind of open id (there are a lot of providers, and most of your users will have google account) provider. In my highscore system I just hash incoming entries with some secret present in APK - this is not very secure, but data are not that valuable and there were no hack attepßts so far.
Every push alert requires active polling from device - also your application shall ask via get request something like "are there new entries since last timestamp" ( but if you already do this, you may as well just download them ) - the alert user via usual android means ( widget, status bar, vibration, playing starwars imperial march... )
I need to add a functionality to my java-based web application that will allow users to click on a link and the application will automatically call the user and another party and connect them in a phone call.
Does anybody know what would this entail?
Thanks
It can be done with Twilio, and their new, easy Conferencing API. Trust me, it's really really simple. Another option might be CloudVox, but I haven't (formally) tried their service yet.
The World-Wide Web Consortium has an integrated set of speech interaction standards that you'll find interesting. There's a markup language called VoiceXML that is analogous to HTML in that web applications generate it. It differs from HTML in that it's specialized for temporally-based speech interactions instead of visual interactions. So instead of looking at a screen you listen to audio prompts and computer-generated speech. Instead of typing and mousing, you speak back and what you say is processed by a speech recognizer or recorded.
There are many companies using VoiceXML to automate voice response systems, and they handle billions of calls per year. You've probably talked to them many times without realizing it. One of the best companies in this space is Voxeo, and they have a developer site at http://evolution.voxeo.com/ that you can play with. Evolution lets you call your web application over an ordinary phone (or Skype). You actually talk to a VoiceXML-based web browser which will fetch a VoiceXML page from your Java application server, "play" it to you, listen to what you say, and then report that back to your app via a form submission, get the next page to render to you, etc.
Another related standard is CCXML, or Call Control XML. You use this to create teleconferences that may or may not include a voice response application.
So it sounds like in your case you want your standard web application to talk to a CCXML server and ask it establish call legs to the web user and to a customer service line. I know that Voxeo Evolution offers CCXML as well.
There are other good companies in this space too. One that comes to mind is TellMe, which was bought by Microsoft a year or two ago. These two companies (and others) offer professional services too.
So I wanted to write this up as an answer to the comment above. The Skype API provides a number of options for telephony in COM, Java and Python:
Skype4Java - https://developer.skype.com/wiki/Java_API
Skype4Py - https://developer.skype.com/wiki/Skype4Py
Skype4COM - https://developer.skype.com/Docs/Skype4COM
They provide a communication and command protocol layer for working with Skype, more info on the API here:
https://developer.skype.com/Docs/ApiDoc/Overview_of_the_Skype_API
It's kind of different for every platform, the Linux version is based on DBus or X11.
Try FreeSWITCH. I have done this before. Its pretty straight forward. Can be a bit hairy when you need to log call accounting and all those stuff. I hopefully would be able to provide you some guidelines and code samples, let me get home first. Cheers.
The good thing in using FreeSWITCH, you will be able to handle multiple calls, and quite a number of. You might need that in future.
Note: You have to use some kind of VoIP provider in order to do that. I was using Gizmo5 that time and it was pretty good.
Sorry buddy, lost the servlet code somewhere. But no worries it was a simple servlet. Fortunately, I had added my example Java code for XML-RPC, into the FreeSWITCH wiki, and actually that was the code my servlet was invoking down the road. Below is the snippet.
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
XmlRpcClient client = new XmlRpcClient();
try {
config.setServerURL(new URL("http://localhost:8080/RPC2"));
config.setBasicUserName("freeswitch");
config.setBasicPassword("works");
client.setConfig(config);
// For external phone calls using VoIP. We will use something like below.
// new Object[]{"originate", "sofia/gateway/gizmo1/6098989898 &bridge(sofia/gateway/gizmo9/0116054545454)"}
// gizmo1, and gizmo9 are the accounts configured under freeswitch gateway configuration.
client.execute("freeswitch.api", new Object[]{"originate", "sofia/internal/1001 &park()"});
} catch (Exception ex) {
ex.printStackTrace();
}
Moreover, you need to configure few things prior doing this. You need to set up the gateway using your VoIP provider settings.
For FreeSWITCH related help, take a look at this SO Thread.
I know of 2 API providers that does what you need:
1) twilio - can connect to 2 or more parties using TwiML (their markup). example
2) Hoiio - very easy to use with 1 line of RESTful api call. example