Chatbots, or “bots” for short, are computer programs that interact with people in a way that mimics human interaction to some degree. The interaction can vary in complexity from simple keyword-driven queries to elaborate conversational systems using natural language processing and AI techniques. This conversational form of human-computer interaction can act as a framework for many types of useful applications.
Early chatbots included academic curiosities like Eliza (1964) and Julia (1994), but now bots are at work all over the internet in customer support, as virtual assistants like Google Assistant, and in many other roles.
Bots in Hangouts Chat
Bots in Hangouts Chat appear as special users marked BOT. Just like people, bots can participate in chat rooms, and they can respond to direct messages. But unlike people, bots only see messages directed to them when a person @mentions them in a chat room, or when a person sends them a direct message.
Bot access to user data
In order to operate in a useful way, a bot needs to know who is invoking it, and how to address that person. Beyond this basic identity data, bots do not have access to user data unless granted explicitly by the user:
- By default, bots can only read the basic identity of users that invoke them. This information includes the user's display name, user ID, email address, and avatar image.
- If a bot needs to access other data to do its job, it can prompt the user to grant it additional access.
Independence from users
Bots aren't associated with any particular user: anyone can add a bot to a room or remove it. Once the bot is added to a room, anyone can @mention it.
Some use cases for bots
Adding bots to a conversational platform like Hangouts Chat lets people ask questions, issue commands, and so on without changing context. On its back end, a bot can access other systems, acting as an intermediary to those systems.
This ability to provide access to a wide range of resources and tools, while maintaining a unified cognitive experience, can provide an excellent framework for many types of applications, including:
- workflow management
- setup and configuration
- order generation
- data collection
Some low-level examples of the type of things you might a bot to do from within the chat room include:
- Look up information — A chatbot can retrieve information based on structured or free text queries entered by the user.
- File ticket — A chatbot can generate a new incident report or other artifact, using information provided by the user.
- Coordinate effort — A chatbot can enhance the way that team members interact with each other, by providing “team memory”, scheduling resources, and so on.
Integrating with G Suite
If you're considering building a Hangouts Chat bot that will integrate with G Suite, consider implementing the bot in Apps Script. This provides your bot with easy access to G Suite services and data such as Sheets, Slides, Docs, and Calendar.
Hangouts Chat API
The Hangouts Chat API provides a number of ways that you can integrate your bots into chat rooms and DMs, but does not provide or dictate any particular way to implement the bot logic. You can create a simple command-driven bot or use any kind of language processing and AI services or modules that you like, and you can do this on a variety of platforms, including:
- Apps Script
- Google Cloud Platform
- Cloud or on-prem HTTP server
See Bot implementation architectures for more on this topic.
When you configure a bot in Hangouts Chat, it must provide an identity; this consists of:
- The bot name
- An avatar image for the bot
- Indentiy of the bot developer
Bots should also provide a help command or the equivalent to help users get started using the bot.
Bot communication with Hangouts Chat
Bots can receive messages from, and send messages to, Hangouts Chat. These messages use defined message formats, which may render as simple text messages or interactive cards in Hangouts Chat.
Bots in direct messages (DM)
You can configure a bot so that it responds to direct messages. This provides a one-to-one conversational interface that involves a single user.
Bots in chat rooms
You can add a bot to a chat room, so that it can respond to specific content that appears in the room. For example, you can specify that any message that begins with "@foobot" is passed to some foobot app and the response appears in the chat room. The following sequence diagram summarizes the bot behavior:
Hangouts Chat communicates with your bot via an endpoint, which may be one of the following types:
- HTTP (web service) endpoints can accommodate various styles of interaction.
- Cloud Pub/Sub endpoints let your bot subscribe to a topic that relays messages from Hangouts Chat, even if the implementation is behind a firewall.
See the Endpoint types section for more about the different ways you can connect Hangouts Chat with your bot.