mebots
v1.2.0
Published
Simple interface to the MeBots API (see mebots.co)!
Downloads
2
Readme
mebots
Usage
First install with npm
or your favorite package manager:
npm install mebots
Import into your project:
const mebots = require('mebots');
// Alternative:
const Bot = require('mebots').Bot;
// If you choose this option, simply instantiate the bot as `new Bot(...)` below.
Instantiate your bot by passing the shortname and token:
// var or let should work too
const bot = new mebots.Bot('your_bot_shortname', 'token (at top of page while editing your bot)')
You will likely want to store the token in an environment variable or config file of some sort. At any rate, don't commit it to GitHub! :)
Finally, use a promise structure to fetch the instance and post a message, using the id
field to fulfill the bot_id
key as discussed in GroupMe's documentation here!
bot.getInstance(receivedGroupId).then((instance) => {
options = { // the parameters you're passing to
// ...
'bot_id': instance.id,
};
// Perform request just like you normally would!
});
Feel free to open an issue if you need help!
See this repository for an example of a fully-functioning GroupMe bot in JavaScript using the MeBots API.