In this guide, an xmpp based client-daemon is used as a chat-bot, this chat-bot is written in C++ and it is based on gloox-xmpp-client library. Xmpp provides an easy way of communication between two clients which are typically behind a firewall. A jabber server with public-ip over internet helps to achieve this secure communication between two xmpp clients.
Following steps explain how to compile and run the xmpp-client-daemon(chat-bot) on raspberry pi. Here is a diagram showing typical setup of remote communication between raspi and a smart phone.
How to prepare raspberry-pi to act as a chat-bot?
(following steps are tested on a raspi running 2017-11-29-raspbian-stretch-lite.img)
Check on your android phone's hangout if "my-raspi-usrname" is online, if so, then send "help" message and the reply would show the list of available commands.
Note-1: For proper operation of xmpp with google account, ensure that your Raspi's account has this allow-less-secur-apps setting enabled.
Note-2: Two xmpp accounts need not be on google, any two jabber accounts would work. Here is an explanation on preparing the jabber accounts.
Following steps explain how to compile and run the xmpp-client-daemon(chat-bot) on raspberry pi. Here is a diagram showing typical setup of remote communication between raspi and a smart phone.
How to prepare raspberry-pi to act as a chat-bot?
(following steps are tested on a raspi running 2017-11-29-raspbian-stretch-lite.img)
- Login to the linux-shell-terminal of your raspi using directly connected keyboard or ssh.
- sudo apt-get update
- sudo apt-get install cmake git libjson-c-dev libgloox-dev openssl
- mkdir /home/pi/xmproxy
- cd /home/pi/xmproxy
- git clone https://github.com/hackboxguy/brbox
- cd /home/pi/xmproxy/brbox/sources
- cmake -H. -BOutput -DCMAKE_INSTALL_PREFIX=/home/pi/xmproxy/buildir -DAUTO_SVN_VERSION=OFF
- cmake --build Output -- install (suffix -j5 incase of quad-core-raspi for faster build)
- cd /home/pi/xmproxy/buildir
- echo "user: my-raspi-usrname@gmail.com" >/home/pi/xmproxy/buildir/xmpp-login.txt;echo "pw: super-secret-pw" >>/home/pi/xmproxy/buildir/xmpp-login.txt
- export LD_LIBRARY_PATH=/home/pi/xmproxy/buildir/lib
- /home/pi/xmproxy/buildir/bin/xmproxysrv --loginfile=/home/pi/xmproxy/buildir/xmpp-login.txt
Check on your android phone's hangout if "my-raspi-usrname" is online, if so, then send "help" message and the reply would show the list of available commands.
enjoy chatting with your raspi-chat-bot!!
Note-1: For proper operation of xmpp with google account, ensure that your Raspi's account has this allow-less-secur-apps setting enabled.
Note-2: Two xmpp accounts need not be on google, any two jabber accounts would work. Here is an explanation on preparing the jabber accounts.
Note-3: steps explained above would work on any debian based linux distro machine.
source code is open, suggestions and contributions are welcome.