HTTP Bot Callback

From SmartBots Developers Docs
Jump to: navigation, search

The Bot HTTP callback is a powerful mechanism used to find out what happens to your bot.

The Bot calls your HTTP script when something important happens: someone invites the bot to a group, gives money to the bot, says something in local chat.

Sometimes you can control your bot's behavior: for example, decide to accept or decline the group invitation.

Using HTTP callback

1. Initialize HTTP callback

Tell your bot that you wish to receive HTTP callbacks: use set_http_callback API call:

// Command bot to send all callback events to you
string params = llDumpList2String([
  "action="  + "set_http_callback",
  "apikey="  + llEscapeURL(yourApiKey),
  "botname=" + llEscapeURL("YourBot Resident"),
  "secret="  + llEscapeURL(botSecretCode),

  "url="     + "",
  "events="  + llEscapeURL("all")
  [HTTP_METHOD,"POST"], params);

2. Parse messages from the bot

Bot calls your HTTP script and passes event-specific parameters. For example, you get the group name and group UUID for group invitation event. See the "Examples" section at the end of the page.

Visit HTTP Bot Callback Events for a complete list of events and their parameters.

3. Reply to the bot

Sometimes the bot expects your reply: to allow joining a group or accepting a frendship offer. This is being done by generating a response string in your HTTP script.

The format of the reply string is similar to URL encoding: key1=value1&key2=value2... For example, the reply to accept group invitation is



In-world event: your bot SamuraiOfLight got invited to the group by Fashion Firethorn. Bot reaction: your HTTP callback script will get the following data from the bot:

avatar_name=fashion firethorn
bot_name=SamuraiOfLight Resident

system_message=Fashion Firethorn (fashion.firethorn) has invited you to join a group.
There is no cost to join this group.
SmartBots: group invitation bots: Direct group inviter
just for L$79 per week! Plus chat manager, notice sender
and a lot of unique features