Chatbot XMPP connect
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.
|XMPP Connect||How to connect to the Userlike chat server|
|Chat Commands||Chat commands your chatbot can use|
|Dashboard integration||Monitor your chatbot's activity|
|Sample Code||Sample code for chatbots|
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:
|Password||Your 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.
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:
|Query Webvisitor info|
|Query Webvisitor info and return result in JSON format|
|Show current chat history|
|Look up Webvisitor's chat history|
|Show Operator stats|
|Show Operator stats and return result in JSON format|
|Show active chats|
|Take screenshot of Webvisitor's browser|
|Query status of an Operator|
|Query status of an Operator and return in JSON format|
|Forward chat to a another Operator|
|Forward chat to a another Operator (returns JSON on error)|
|Forward chat to a another Operator Group|
|Forward chat to a another Operator Group (returns JSON on error)|
|Forward chat to the next available Operator|
|Forward chat to the next available Operator (returns JSON on error)|
|Set name for Webvisitor|
|Set additional value 1|
|Set additional value 2|
|Set additional value 3|
|Set custom data value|
|Set email for Webvisitor|
|Set locale for chat session|
|Add a private note to the chat transcript|
|Send chat transcript via email to the Webvisitor when the chat session has ended|
|Send current chat transcript to specified email address|
|Send Webvisitor to a local URL|
|Offer Webvisitor given download|
|Show available chat topics|
|Show available chat statuses|
|Block Webvisitor from chat|
|Send an image to Webvisitor|
|Send a video to Webvisitor.|
|Send a list of predefined answers to Webvisitor.|
|Send a list of links with a title text to Webvisitor.|
|Correct a typo in your last message|
|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:
See the examples below for more details on how to integrate these commands with your bot logic.
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.
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!