reply_dialog
From SmartBots Developers Docs
Virtually "presses" a pop-up dialog button (which was displayed by an in-world script).
Variables
The following table shows input values (you send them with the API call) and returned output values.
Variable | Required | Description | ||
---|---|---|---|---|
This API command applies only for Standard bot | ||||
Input basic parameters: | ||||
action | yes | = reply_dialog | ||
apikey | yes | Your personal developer's API key. | ||
botname | yes | Your bot's SL login. | ||
secret | yes | Bot access code of your bot. | ||
dataType | optional | Set to "json" to get JSON reply instead of URL-encoded string | ||
custom | optional | The custom data (string) to be passed back to caller script. This value will be returned back to the caller in HTTP response. | ||
Input: | ||||
channel | yes | the dialog channel (either positive or negative value) | ||
object | yes | UUID of the object which sent us the dialog | ||
button | yes | the text of the dialog button to press | ||
Output: | ||||
(to be received in http_response LSL event, see docs for details) | ||||
result | OK - command completed successfully FAIL - command failed | |||
resulttext | Detailed reason for the failure. | |||
custom | The value from input "custom" parameter. See above. |
Examples
This script does the following:
- Waits until you touch it
- Sends the dialog window to your bot
- Reports the bot menu selection to you
Place this code to an in-world object, and replace variables at the beginning with your values (read more about api key and Bot access code);
LSL Code
string sbApiKey = "...";
string sbBotName = "YourBotName Resident";
string sbBotAccessCode = "bot-access-code";
// Hint: sbBotName is the bot's name. However, you can place
// your SL name here to see the dialog yourself (and even touch the button).
// Obliviously, HTTP API won't make you touching the menu automatically :)
key httpReq = NULL_KEY;
integer CHANNEL = -11;
default {
touch_start(integer total_number) {
llOwnerSay("Searching for UUID, bot "+sbBotName);
// Look for bot nearby (we can use HTTP API name2key here, too)
llSensor(sbBotName, NULL_KEY, AGENT, 96, PI);
}
sensor(integer num) {
// We've detected our bot!
// Hint: If "Found" message does not appear,
// check that bot is within 96 meters range.
key id = llDetectedKey(0);
llOwnerSay("Found bot UUID: "+ (string)id +
", sending dialog menu and waiting 3 seconds...");
// Sending dialog to the bot
llListen(CHANNEL, sbBotName, NULL_KEY, "");
llDialog(id, "Are you human or bot?", ["human", "bot", "both"], CHANNEL);
// Wait 3 seconds and then make bot reply
llSetTimerEvent(3);
}
timer() {
llOwnerSay("Now sending HTTP command to the bot " +
"to click the menu's item 'bot'...");
// The HTTP API command is being sent here:
string params = llDumpList2String([
"action=" + "reply_dialog",
"apikey=" + llEscapeURL(sbApiKey),
"botname=" + llEscapeURL(sbBotName),
"secret=" + llEscapeURL(sbBotAccessCode),
"channel=" + (string)CHANNEL,
"object=" + (string)llGetKey(),
"button=" + llEscapeURL("bot")
], "&");
llHTTPRequest("https://api.mysmartbots.com/api/bot.html",
[HTTP_METHOD, "POST"], params);
llSetTimerEvent(0);
}
listen(integer channel, string name, key id, string message) {
// We've got a reply from menu!
llOwnerSay("Bot touched the menu item: " + message);
}
}
Important note
Actually the script is not complete. You may need to know:
- the moment WHEN bot gets a popup menu
- the channel that menu uses (since menu's channel can vary)
This example is very basic (you can use it when you exactly know that dialog has been shown, and a dialog's channel). New HTTP API callback functions (in development yet) will allow you to get that info from bots.
<< return back to Bot commands
(Miss an API call or parameter? Submit your request in forum)