# reply_dialog

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.


:::info
This API command applies only for Standard bot

:::

## Input basic parameters

| Variable | Required | Description |
|----------|----------|-------------|
| action   | yes      | = reply_dialog |
| apikey   | yes      | Your personal [developer's API key](/doc/developers-api-key-tw8bQj4LSJ) |
| botname  | yes      | Your bot's SL login |
| secret   | yes      | [Bot access code or API token](https://www.mysmartbots.com/docs/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

| Variable | Required | Description |
|----------|----------|-------------|
| 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*](/doc/doing-http-api-calls-c6FSEMF7bP) *for details)*

| Variable | Description |
|----------|-------------|
| result   | OK - command completed successfully<br>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](https://www.mysmartbots.com/docs/Bot_access_code)):

## LSL Code

```csharp
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).
// Obviously, 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.