Chatbot XMPP connect

Intro

For those of you who still connect their chatbots via XMPP, we provide the necessary pointers and examples below. Please note that future chatbot development will focus on our Chatbot HTTP integration, so you might consider switching to that.

TopicDescription
XMPP ConnectHow to connect to the Userlike chat server
Chat CommandsChat commands your chatbot can use
Dashboard integrationMonitor your chatbot's activity
Sample CodeSample code for chatbots

XMPP Connect

An existing Userlike account and an XMPP library are all you need to write a chatbot and connect it to the Userlike chat server. The required credentials:

Server/Hostwww.userlike.com
Usernameyour-username@userlike.com
PasswordYour Userlike password

Since XMPP is an open standard, you can choose from many existing libraries for different programming languages. The following coffeescript example shows how to connect to the Userlike chat server using the node-xmpp library.

Saving above code in "bot.coffee" you can now connect to the Userlike chat server in your shell, providing your Userlike credentials as follows:

For other XMPP libraries, the process is similar. Refer to your library's documentation when you are unsure how to use your Userlike credentials with it.

Chat Commands

Once your bot is connected to the Userlike chat server it can interact with your Webvisitors. Even better though, it has access to the Userlike chat commands, giving it full control over the initiated chat session. So your chatbot can collect and store data from your Webvisitors, send them to special parts of your web page or forward the current chat session to a human colleague.

The following commands are currently available, allowing for powerful automation patterns:

CommandDescription
$infoQuery Webvisitor info
$info.jsonQuery Webvisitor info and return result in JSON format
$sessionShow current chat history
$historyLook up Webvisitor's chat history
$statsShow Operator stats
$stats.jsonShow Operator stats and return result in JSON format
$activeShow active chats
$screenshotTake screenshot of Webvisitor's browser
$macroShow macros
$queryQuery status of an Operator
$query.jsonQuery status of an Operator and return in JSON format
$forwardForward chat to a another Operator
$forward.jsonForward chat to a another Operator (returns JSON on error)
$groupForward chat to a another Operator Group
$group.jsonForward chat to a another Operator Group (returns JSON on error)
$anyForward chat to the next available Operator
$any.jsonForward chat to the next available Operator (returns JSON on error)
$nameSet name for Webvisitor
$additional01Set additional value 1
$additional02Set additional value 2
$additional03Set additional value 3
$customSet custom data value
$emailSet email for Webvisitor
$localeSet locale for chat session
$noteAdd a private note to the chat transcript
$sendSend chat transcript via email to the Webvisitor when the chat session has ended
$dispatchSend current chat transcript to specified email address
$pushSend Webvisitor to a local URL
$downloadOffer Webvisitor given download
$topicShow available chat topics
$statusShow available chat statuses
$blockBlock Webvisitor from chat
$imageSend an image to Webvisitor
$videoSend a video to Webvisitor.
$chipsSend a list of predefined answers to Webvisitor.
$linksSend a list of links with a title text to Webvisitor.
$quitQuit chat
$helpPrint help
s/old/new/Correct a typo in your last message
![macroname]Send given text macro

A small example of a chatbot whose only task is to connect you to the next available human Operator, using the following commands: $quit $any.json $forward.json !bye

See the examples below for more details on how to integrate these commands with your bot logic.

Dashboard Integration

While we welcome automation for many tasks, we still want to monitor our trusted chatbot's activity. They are our loyal servants after all - or aren't they? Thankfully, all of your chatbot's activity is available via transcripts in your Userlike Dashboard, just like with any human Operator.

Continuing our simple example from above, the following interaction of a Webvisitor with your chatbot...

... shows up like every other chat transcript in the Userlike Dashboard:

You can easily filter all your chatbot's interactions for regular audits and check that it does its job as expected. Filtered results also include interactions that were only initiated by your chatbot and then switched to a human Operator, so you truly have a full overview.

Sample Code

We have started a GitHub repository to provide you with some complete code examples. Here is a full example for a (simple) chatbot.

Further examples/pull requests are welcome!