Build a “Management” Chat Bot in 5 steps with Google AppEngine

Google AppEngine provides very cool features. One of these features is the XMPP API, that allows you to write apps that can interact with users through XMPP clients, e.g. Jabber or GTalk.

Here’s a quick description how to create a chat bot which will help you to work for efficient. I think it has the potential to replace at least some managers. 😉

1. Create a new web application project “”. Rename the generated servlet “ChatbotServlet” and adjust web.xml
2. Open the servlet class and add a new attribute that provides access to the XMPP service

      private static final XMPPService xmppService =

3. Add a doPost method which will be called when a new message is received. In this method I will parse the incoming message and generate a reply, in our case a simple echo.

      public void doPost(HttpServletRequest request, HttpServletResponse response)
          throws IOException {
      Message message = xmppService.parseMessage(request);
      Message reply = new MessageBuilder()

4. Now we need to enable the XMPP service for our app. Open the appengine-web.xml file in the war/WEB-INF folder and add the following tag:


5. As the final step we need to hook our servlet to a standard URL pattern that is used for the XMPP service. Open the web.xml file in the WEB-INF folder and change the existing servlet mapping:

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi=""
xsi:schemaLocation="" version="2.5">

That’s it! Deploy the application to the Google App Engine to be able to chat with it.

Every application has it’s own Jabber/GTalk ID: or Add that ID to your GTalk list and you will be able to interact with the application.

References: and

I would like to thank Ralf GĂźldemeister for providing most of the content of this blog entry.

To learn more about the Google App Engine please have a look at my Google App Engine Java Tutorial. You can also follow me on Twitter.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Web and tagged , . Bookmark the permalink.

One Response to Build a “Management” Chat Bot in 5 steps with Google AppEngine

Comments are closed.