https://github.com/poetic/chatterbox
a chat bot for meteor apps
https://github.com/poetic/chatterbox
Last synced: about 2 months ago
JSON representation
a chat bot for meteor apps
- Host: GitHub
- URL: https://github.com/poetic/chatterbox
- Owner: poetic
- Created: 2015-07-10T05:24:56.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-04T15:30:21.000Z (over 9 years ago)
- Last Synced: 2025-03-24T20:22:59.584Z (2 months ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 5
- Watchers: 9
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Chatterbox
# Installation
`meteor add poetic:chatterbox`
# Usage
First initialize your chatbot with the `Chatterbox` constructor, passing a name as the only parameter.
```
Chatbot = new Chatterbox('Bot');
```Then call `listen` on your new Chatbot.
```
Chatbot.listen(Posts, {listenTo: 'body', listenFor: /testing/, chatAs: 'author'}, (userId, post) => {
// userId and post are the same objects passed from the collection hooks package
})
```Your Chatbot will now listen to the `body` property on every new post that is created. When the post's body passes a regex test against your `listenFor` argument the callback will be run.
If you'd like your Chatbot to get in on the conversation simply call `chat`.
```
Chatbot.chat(Posts, {chatAs: 'author',
message: {
// properties of your Posts collection go here
}
})
```Make sure that, whether you `chat` or `listen`, always `chatAs` the same property, or your bot will start talking to itself. The above example will yield a post by the Chatbot that has the name `Bot` attached to the `author` property.