Bots

Ever wish you could walk around the office with an army of robots to do your bidding?

Bumblebee, snap a photo of that whiteboard and make sure everyone gets a copy.
Sideswipe, find a good time for me to meet with Mike and Jason.
Jazz, stop pushing all the buttons in the elevator!

Okay, actual robots might be impractical. Spark Bots, on the other hand, are the way to create machine accounts that can automate routine tasks and inject contextual content into meetings and group conversations.

Bots vs Integrations

Before diving in we should clarify some terminology.

If you're logged in to the developer portal, you should see the My Apps section. My Apps contains two concepts: Integrations and Bots.

Integrations invoke the Spark APIs on behalf of other Spark users. Integrations use an OAuth Grant Flow to authenticate Spark users and authorize the use of an application with their Spark account. See the Integrations guide for more information.

Bots differ from Integrations in that they appear as their own users and post content on their own behalf. In group rooms, Bots look like People and are, in many ways, just like regular users.

Creating a Spark Bot Account

Creating a Spark Bot is super easy. From the My Apps section, click on the plus sign and choose Create a Bot from the wizard. You'll be asked to provide some basic information about the Spark Bot: display name, username and icon. These fields are end-user facing, so make them as descriptive as possible. Only the bot's "first name" will be shown when mentioned in messages, so try to avoid spaces in the display name.

Once you've filled out the registration form click Add Bot and if everything goes smoothly you're all set!

The bot's Access Token will only be displayed once. Make sure to scroll down on the confirmation page, copy the token and keep it somewhere safe. If you misplace it, you can always generate a new one by finding the bot in My Apps and selecting "Regenerate Access Token" from the edit page.

Types of Spark Bots

Bots come in all different shapes and sizes. Some common types are:

Notifiers

Notifier bots typically respond to events in external services and post a summary in Spark. For example, a GitHub Bot may listen for commits on a particular repo and post the committer's name and comment into a team room set aside for this purpose. Or a Deal Bot that lives in an account-specific room and posts updates from a CRM along with relevant news about the company like a product launch or earnings report.

Controllers

Controller bots act as a text-based remote control for external services. For example, a JIRA Bot may allow software engineers and product managers to control or query information from the popular bug tracking system JIRA, all from the comfort of a Spark room.

Controller bots are generally passive, waiting for someone in the room to issue a command. In group rooms, bots can only see messages in which they are mentioned (1:1 rooms bots can see all messages as they are automatically "mentioned"). Your users are required to mention the bot preceding the command like @jira find WEBSITE-22 where @jira is the bot's name.

Currently, the Spark SDK does not have support for extracting commands. You'll need to parse it out after the mention. Future versions of the Spark SDK will have built-in support for commands. Keep your eyes on the blog for updates.

Assistants

Virtual assistants are the holy grail of chatbots. At minimum, an assistant should understand natural language, allowing the user to ask it questions as they would to a human.

Recent advancements in NLP (Natural Language Processing) have made understanding natural language requests not only possible, but quite accessible to the average developer. Most notably, Google launched Google Cloud Natural Language API in the summer of 2016, providing syntax parsing, sentiment analysis and deep noun classification.

Responding to natural language is a good first step but a truly exceptional assistant bot will be conversational, using past interactions to contextualize the most recent query. This is a very complex problem domain; luckily there are companies like API.ai providing a conversational platform built specifically for chat bots.

Differences between Bots and People

One key difference between Spark Bots and regular users is that, in group rooms, bots only have access to messages in which they are mentioned. This means that messages:created webhooks only fire when the bot is mentioned in a room.

Also, GET /messages requires that you specify a special ?mentionedPeople=me query parameter.

GET /messages?mentionedPeople=me&roomId=SOME_INTERESTING_ROOM
Authorization: Bearer THE_BOTS_ACCESS_TOKEN

Bot Frameworks & Tools

Nick Marus over at Presidio has written an awesome Spark Bot framework called flint.

You can now develop bots for Cisco Spark using the Botkit framework! Botkit is a popular open source bot framework with advanced conversational support as well as integrations with a comprehensive array of natural language processing and storage providers. You can get started with Botkit by cloning the Cisco Spark Botkit Starter Kit.

Keep your eyes on our blog for updates and other community-supported tools!