Showing posts with label app engine. Show all posts
Showing posts with label app engine. Show all posts

Wednesday, December 2, 2009

XMPP Bots - XMPPGuru

xmppguru@appspot.com

XMPP Provides easy and clean ways to build XMPP Bots, as I showed on the previous post, we can use Google AppEngine to create 24h online, zero-maintenance Bots.


One interesting Bot is a Guru One, the main objective of this Bot is to clarify topics, answer general knowledge questions and retrieve hints for general opinion.
You can add it to your GTalk's / Jabber Contacts: xmppguru@appspot.com


Examples of general knowledge:
Question: What is Aerosmith?
xmppguru: Aerosmith is an American hard rock band, sometimes referred to as "The Bad Boys from Boston" and "America's Greatest Rock and Roll Band".

Question: What is an atomic bomb?
xmppguru: nuclear weapon: an explosive device whose destructive power is due to the uncontrollable release of energy from the fission of heavy nuclei, usually uranium-235 or plutonium-239, by neutrons sustaining a rapid chain reaction

Question:  Who invented the harpoon?
xmppguru: Endangered Species question: Who invented the harpoon cannon? Sven (or Svend) Foyn (1809-1894) was a whaler born in Tønsberg in southeast Norway. In 1856, he invented the bow ... 

Examples of general opinion:
Question: What is a good song?
xmppguruWhat is a good song to "give" someone who you are …


QuestionDo you trust god?
xmppguruThe Bible tells us to have faith: (Hebrews 11:6 NIV) And without faith it is impossible to please God, because anyone who comes to him must believe that he exists and that he ...


The Bot is not meant to have conscience neither deep lexical interpretation, the goal is to answer your question when possible, something directly with a straight answer, but something also vague hints.
For unknown answers the principe is the same of Horoscope, but in a scientific way. 
the best way of discovering how it works, purpose and functionality is by testing it.

Sometimes you will be surprised even asking by your full name. In the same way you will be surprised by crappy answers. Enjoy!

Sunday, November 29, 2009

Google App Engine XMPP Services Example



Google App Engine released the XMPP Services a while ago. The service started very basic and bad, but since then, it is improving a lot and have potential to be really worthy to build XMPP Services over it.
Unfortunately currently you might only be able to write bots. Which is not that bad specially for developers that are starting with XMPP and App Engine.

The documentation is not that good so far, but it was enough to create an EchoBot Demo App, you can download the full source here.
To use it, just explode the folder, make sure you have Google App Engine SDK configured, set your application ID, and deploy.
I strongly recommend to use Eclipse AppEngine Plugin for those tasks.

Quick Tutorial

Receiving Messages are handled by your application like an HTTP Post Request:
@SuppressWarnings("serial")
public class XmppbotServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException {


Parsing Received Messages is piece of cake. AppEngine API is handy in that sense:
XMPPService xmpp = XMPPServiceFactory.getXMPPService();
        Message message = xmpp.parseMessage(req);


Creating a Response Message is also very simple:
JID fromJid = message.getFromJid();
String body = message.getBody();

// Create an Echo Message
Message response = new MessageBuilder().withMessageType(
message.getMessageType()).withBody(body)
.withRecipientJids(fromJid).build();


Now we send it back, without any specialist XMPP Knowledge required.
boolean messageSent = false;
SendResponse status = xmpp.sendMessage(response);
messageSent = (status.getStatusMap().get(fromJid) == SendResponse.Status.SUCCESS);

if (!messageSent) {
// An Error Occurred
}


Now you can create an XMPP Bot with just a few line of simple Java code.
Remarks:

  • Your Bot will auto accept every XMPP contact add request, which is quite handy too. To test your Bot, just open your XMPP Account in your preferred Client. And add the contact: YourAppName@appspotchat.com
  • It will auto-accept your request, and if your service is running, it will be shown as available.
  • You can also use aliases like: Whatever@YourAppName.appspotchat.com

Monday, September 21, 2009

Google AppEngine Limiting Telephony Application

If you sign up for a Google App Engine account you will have the following statement in the Terms of Service:

"You agree not to use the XMPP API to operate or to enable any telecommunications service or in connection with any applications that allow users to place calls to or receive calls from any public switched telephone network."

Google basically is blocking any usage of XMPP to communicate with telephony networks. In practical terms is limiting any usage of XMPP API for a SIP/Jingle or H323/Jingle Gateway, etc...

Although it is not that bad, once it implicit allows the usage for Pure Internet Calling purposes. It remind me about the all discussion around FCC, on Google "fighting" with Apple to get his Application into IPhone AppStore.
As I mentioned before, all this overrated discussion is possibly part of a Marketing Plan to Advertise the Google Voice Service, as it showed itself a big failure so far.
Once Google is following exactly the same bounds of restrictions as Apple in the App Engine.

This post does not have as intention, judge the Apple or Google for their games and strategies. But it has the purpose of warning and public awareness about Voice Over IP Market, now played by new powerful players.