playground_webhook
From SmartBots Developers Docs
Fires when the script’s webhook receives an HTTP request from your server.
Bot.on("playground_webhook", function(event) { ... });
Reference
This event comes with the following event object:
Variable | Required | Description | |
---|---|---|---|
event object properties: | |||
name | string | The name of the event | |
bot_slname | string | Your bot’s Second Life name (e.g. "smartbots Resident"). | |
hookId | string | Identifier of the current webhook (also visible at the end of the request’s URL). | |
correlationId | string | A unique identifier for this request. | |
payload | object | Parsed JSON data from the request. |
Important note
If the payload on the request is not valid JSON, the payload object will come through as an empty object.
It is best practice to place the event above the http.requestWebhook() command, to catch any early requests.
Example
Bot.on("playground_webhook", (event) => {
console.log("Webhook received:", event);
});
Sending a request from a remote server
Sending a POST request to the webhook URL, and including the Authorization and Content-Type headers. The payload is JSON.
curl --location 'https://gate07.play.mysmartbots.com/userhook/ca4687a9-db28-43ee-9bb8-cf80100t41cf' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer PBubZ9CbPd9PWUm2n6L5ygfHkhCOUf8V' \
--data '{"exampleData": 123456}'
Example response:
{
"success": true,
"correlationId": "bb980f2e-b3e0-4eee-acd0-f5041af6a449"
}
Example playground_webhook event:
{
"name": "playground_webhook",
"bot_slname": "smartbot Resident",
"hookId": "ca4687a9-db28-43ee-9bb8-cf80100t41cf",
"correlationId": "bb980f2e-b3e0-4eee-acd0-f5041af6a449",
"payload": {
"exampleData": 123456
}
}
Check the complete example script and scenario.