UNPKG

6.35 kBMarkdownView Raw
1# Botkit - Building Blocks for Building Bots
2
3[![npm](https://img.shields.io/npm/v/botkit.svg)](https://www.npmjs.com/package/botkit)
4[![David](https://img.shields.io/david/howdyai/botkit.svg)](https://david-dm.org/howdyai/botkit)
5[![npm](https://img.shields.io/npm/l/botkit.svg)](https://spdx.org/licenses/MIT)
6[![Build Status](https://travis-ci.com/howdyai/botkit.svg?branch=master)](https://travis-ci.com/howdyai/botkit)
7
8**Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.**
9
10## The information in this document is for the brand new 4.0 branch of Botkit! If you're looking for documentation for previous versions, [look here](https://github.com/howdyai/botkit-docs).
11
12## Install Botkit
13
14The best way to get started locally with Botkit is by installing our Yeoman template, and using it to create a new Botkit project.
15This will install and configure a starter kit for you!
16
17```bash
18npm install -g yo generator-botkit
19yo botkit
20```
21
22### Remix on Glitch
23
24Want to dive right in? [Remix one of our starter kits on Glitch](https://glitch.com/botkit). You'll start with a fully functioning app that you can edit and run from the browser!
25
26 [![Remix on Glitch](https://github.com/howdyai/botkit/blob/main/packages/docs/glitch.png?raw=true)](https://glitch.com/botkit)
27
28## Build Your Bot
29
30The goal of Botkit is to make it easier and more fun to build software that talks and works like a robot!
31Building a bot should feel cool, and not too technically complicated.
32
33Botkit handles all the nitty gritty details like
34API calls, session management and authentication,
35allowing you to focus on building COOL FEATURES for your
36bot using middleware and event handlers.
37
38The toolkit is designed to provide meaningful building blocks for creating conversational user interfaces - with functions like `hears()`, `ask()`, and `reply()` that do what they say they do.
39
40The [full documentation for Botkit's capabilities begins here »](../docs/index.md)
41
42## Platform Support
43
44Botkit can connect to multiple messaging channels through the [Microsoft Bot Framework Service](https://dev.botframework.com).
45No plugins are necessary to use the Bot Framework service, and bots can be developed locally using the [Bot Framework Emulator](https://aka.ms/botframework-emulator).
46
47The Botkit project includes several official adapters. Using these plugins, your bot can communicate directly with the messaging platforms.
48
49* [Self-hosted web chat](../botbuilder-adapter-web)
50* [Slack](../botbuilder-adapter-slack)
51* [Webex Teams](../botbuilder-adapter-webex)
52* [Facebook Messenger](../botbuilder-adapter-facebook)
53* [Twilio SMS](../botbuilder-adapter-twilio-sms)
54* [Google Hangouts](../botbuilder-adapter-hangouts)
55
56Additional adapters can be found by [searching npm for Bot Framework-compatible adapters](https://www.npmjs.com/search?q=botbuilder-adapter). The open source community has created a variety of plugins and extensions to Bot Framework. Check out the [Bot Builder Community Repo](https://github.com/BotBuilderCommunity/botbuilder-community-js) for additional adapters, storage connectors and middlewares.
57
58[Platform specific documentation can be found on the main docs site »](../docs/platforms/index.md)
59
60### Hearing Keywords
61
62Most bots do their thing by listening for keywords, phrases or patterns in messages from users. Botkit has a special event handler called `hears()` that makes it easy to configure your bot to listen for this type of trigger.
63
64```javascript
65controller.hears(['string','pattern .*',new RegExp('.*','i')],'message,other_event', async (bot, message) => {
66
67 // do something!
68 await bot.reply(message, 'I heard a message.')
69
70});
71```
72
73[Read more about hearing things ›](../docs/core.md#matching-patterns-and-keywords-with-hears)
74
75### Responding to Events
76
77Bots can respond to non-verbal events as well, like when a new user joins a channel, a file gets uploaded, or a button gets clicked. These events are handled using an event handling pattern that should look familiar. Most events in Botkit can be replied to like normal messages.
78
79```javascript
80controller.on('channel_join', async (bot, message) => {
81
82 await bot.reply(message,'Welcome to the channel!');
83
84});
85```
86
87[See a full list of events and more information about handling them ›](../docs/core.md#receiving-messages-and-events)
88
89### Middleware
90
91In addition to taking direct action in response to a certain message or type of event, Botkit can also take passive action on messages as they move through the application using middlewares. Middleware functions work by changing messages, adding new fields, firing alternate events, and modifying or overriding the behavior of Botkit's core features.
92
93Middleware can be used to adjust how Botkit receives, processes, and sends messages.
94
95```javascript
96// Log every message received
97controller.middleware.receive.use(function(bot, message, next) {
98
99 // log it
100 console.log('RECEIVED: ', message);
101
102 // modify the message
103 message.logged = true;
104
105 // continue processing the message
106 next();
107
108});
109
110// Log every message sent
111controller.middleware.send.use(function(bot, message, next) {
112
113 // log it
114 console.log('SENT: ', message);
115
116 // modify the message
117 message.logged = true;
118
119 // continue processing the message
120 next();
121
122});
123```
124## Documentation
125
126[Full documentation of Botkit, including a class reference, can be found on the docs site](../docs/index.md).
127
128## [Change Log](https://github.com/howdyai/botkit/blob/master/changelog.md)
129
130## Community & Support
131
132Join our thriving community of Botkit developers and bot enthusiasts at large.
133Over 10,000 members strong, [our Github site](https://github.com/howdyai/botkit) is
134_the place_ for people interested in the art and science of making bots.
135Come to ask questions, share your progress, and commune with your peers!
136
137You can also find help from members of the Botkit team [in our dedicated Cisco Spark room](https://eurl.io/#SyNZuomKx)!
138
139## About Botkit
140
141Botkit is a part of the [Microsoft Bot Framework](https://dev.botframework.com).
142
143Want to contribute? [Read the contributor guide](https://github.com/howdyai/botkit/blob/master/CONTRIBUTING.md)
144
145Botkit is released under the [MIT Open Source license](https://github.com/howdyai/botkit/blob/master/LICENSE.md)