Creating a bot

Before you use the MeBots API, you need to create a bot.

  1. To create a bot, first ensure that you're signed in to MeBots.
  2. Click "Create Bot" in the toolbar.
  3. Fill out the form! Most fields are not mandatory, but will help people locate and use your bot more effectively.
  4. Hit submit to create your bot.
  5. When the creation is successful, you will notice that there is a new "Token" input at the top, with an automatically generated hexadecimal string. Take note of this token and your bot's shortname, as you will need them for authentication from your bot's code later on. Do not share the token with anyone.

Authenticating your bot with the API

NOTE: There are official premade libraries for some languages that handle connection logic for you, so you can more easily integrate the MeBots API with your bot code. Choose your language: Python, JavaScript, Ruby. Please see the READMEs of those projects for detailed information on API interaction in these languages. Each library has a corresponding example bot demonstrating one possible way to implement it into a bot program: Python, JavaScript, Ruby.

If there's no library for your language, or if you want to handle things yourself, you will need to communicate directly to the MeBots API. Don't worry—this process is quite simple!

The entire API is essentially one endpoint, which allows you to provide the ID of a group (which is available in received message data) and get back the bot ID of the version of your bot which is in that group. This way, your bot doesn't need to worry about keeping track of which servers you're in. MeBots does that for you.

To get your instance's ID, you'll need to make a GET request to http://mebots.co/api/bot/{shortname}/instance/{group_id}, substituting {shortname} for the shortname of your bot, and {group_id} for the ID of the group. You will receive a JSON response such as the following:

{"id": "0123456789abcdef"}

The response can be parsed as JSON, and you can pass the id field as the bot_id parameter to the message post endpoint described in GroupMe's documentation here.