The BBMBot example application demonstrates how to build a chat bot in Node.js using BlackBerry Spark Communications Services. The BBMbot uses the www.botlibre.com webservice as an example of how to generate responses.
Demo video: Integrate Chat Bots into your Apps
With the BBMBot example, your application can do the following:
- Invite the bot to a 1:1 or multi-person chat.
- In a 1:1 chat, write to the bot, and the bot will respond.
- In a multi-person chat, the bot will respond only to messages which begin
with
@bbmbot
.
This example requires the Spark Communications SDK, which you can find along with related resources at the locations below.
- Instructions to Download and Configure the SDK.
- Getting Started with Node.js instructions in the Developer Guide.
- API Reference
Getting started video
This example application works in a sandbox domain with user authentication disabled and the BlackBerry Key Management Service enabled. See the Download & Configure section of the Developer Guide to get started configuring a domain in the sandbox.
The bot uses the Bot Libre chatbot service to provide responses to messages. An account can be created by going to https://botlibre.com
The bot can be created by choosing:
- Sign up (and complete sign up procedure)
- Create (and fill in bot information)
- Then choose 'Embed' and copy the application and instance information, it will be used below when configuring the example.
When you have a domain in the sandbox and a Bot Libre chat bot setup, edit
BBMBot's config_mock.js
file to configure the example with your domain ID,
a key passcode, and your Bot Libre chat bot's information.
Set the sdkConfig.domain
parameter to your sandbox domain ID.
sdkConfig: {
domain: 'your_domain_id'
},
Set the key_passcode
property to a passcode of your choosing. The passcode
is used to protect the bot's keys stored in the BlackBerry Key Management
Service.
key_passcode: 'passcode',
Set the botLibre
property to the object containing the application and
instance information that you copied earlier while setting up your Bot Libre
chat bot.
botLibre: {
application: 'your_botlibre_application',
instance: 'your_botlibre_instance'
}
To setup the runtime dependencies of the BBMBot example application, you must first install the bbm-enterprise Node.js bundle.
yarn add <path/to/bbm-enterprise-*.tgz> --prod
To setup the remaining runtime dependencies, must run yarn install --prod
.
Run node BBMBot
in the BBMBot's application directory to run the BBMBot
example application. By default, the BBMBot's user ID is
SparkCommunicationsBot
. If you want to change this, it can be changed in
the config_mock.js
file.
You can use the Rich Chat example
application
to start a chat with the SparkCommunicationsBot
user.
These examples are released as Open Source and licensed under the Apache 2.0 License.
This page includes icons from: https://material.io/icons/ used under the Apache 2.0 License.
If you find a issue in one of the Samples or have a Feature Request, simply file an issue.