Now that we've built a simple bot, wouldn't it be nice if it were a bit more intelligent and useful? Let's extend our echo bot to do three additional things. First, we'll have it accept presence subscription requests so that users can see when the bot is online. We'll then tell it to get a result from DuckDuckGo's Instant Answers API (https://duckduckgo.com/api), and we'll implement chat state notifications so that it looks like the bot is thinking about the answer and responding.
In Chapter 2, Diving into the Core XMPP Concepts, we introduced presence subscriptions as a way of allowing other users to see your status or availability. To make it possible for other users to see the current availability of our bot, we'll automatically approve any presence subscription requests as they are received.
Recall that a presence subscription request looks as follows:
<presence from="[email protected]/porch" to="[email protected]" type...