Sending XMPP messages from Google App Engine with html

ESP32 Development Board WiFi+Bluetooth Ultra-Low Power Consumption Dual Cores ESP-32 ESP-32S Board
Integrated antenna and RF balun, power amplifier, low-noise amplifiers, filters, and power management module. The entire solution takes up the least amount of printed circuit board area. This board is used with 2.4 GHz dual-mode Wi-Fi and Bluetooth chips by TSMC 40nm low power technology, power and RF properties best, which is safe, reliable, and scalable to a variety of applications.
Since this took me a while to figure out I’d like to share with you. I wanted to extend Feederator to send incoming news items to the users XMPP client. What worked pretty fast was sending plain text messages:

XMPPService xmpp = XMPPServiceFactory.getXMPPService();
JID jid = new JID(xmppAddress);
Message msg = new MessageBuilder()
    .withBody(“New post arrived”)
if (xmpp.getPresence(jid).isAvailable()) {
    SendResponse status = xmpp.sendMessage(msg);
    messageSent = (status.getStatusMap().get(jid) == SendResponse.Status.SUCCESS);
    if (messageSent) {“message sent”);

But to send parts of the message bold and maybe even displaying pictures was trickier. But I finally figured it out. Change the part with the message:
String message = “<body>Plain text message</body>”
   + “<html xmlns=’’>”
   + “<body xmlns=’’>”
   + “<B>bold text</B> and normal text”
   + “</body>”
   + “</html>”;
Message msg = new MessageBuilder()
By adding the .asXml(true) parameter you tell the XMPP service that you take care yourself of the content of the message. Pay attention to the fact that you always should send a normal elment for the plain text. Not all XMPP/ Jabber clients unterstand the xhtml-im extension. The specification ( says that the plain text should always tell the same as the element with markup and that clients are free to ignore the xhtml-im tag. Also note that clients are free to display the text defined by the alt attribute of a <img> tag and not the picture.

Posted by squix78


  1. The GTalk client doesn't. But the beauty of it is that with the double body tag the clients which understand the XHTML-IM extension will display it. So, even if my message is send over the GTalk server my marked up message will be displayed on Pidgin, Audium or other popular XMPP clients… But, there's still a unsolved problem with encoding…

  2. Do you have any idea how we can send utf-8 chars w/ this method. If I don't build the message asXml and send out only a single body, I can see characters like "ş ğ ü ı ç" at my message. But when I build it asXml to have an html those characters are seen as "? ? ? ? ?". Can you advice anything?

Leave a Reply