Difference between revisions of "Bot Playground/Events/playground webhook"
From SmartBots Developers Docs
(Created page with "{{DISPLAYTITLE: playground_webhook}} <onlyinclude>Fires when the script’s webhook receives an HTTP request from your server.</onlyinclude> <syntaxhighlight lang="javascript...") |
|||
Line 32: | Line 32: | ||
== Request Example == | == Request Example == | ||
Sending a POST request to the webhook URL, and including the Authorization and Content-Type headers. The payload is JSON. | Sending a POST request to the webhook URL, and including the Authorization and Content-Type headers. The payload is JSON. | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="bash"> |
curl --location 'https://gate07.play.mysmartbots.com/userhook/ca4687a9-db28-43ee-9bb8-cf80100t41cf' \ | curl --location 'https://gate07.play.mysmartbots.com/userhook/ca4687a9-db28-43ee-9bb8-cf80100t41cf' \ | ||
--header 'Content-Type: application/json' \ | --header 'Content-Type: application/json' \ |
Revision as of 10:04, 11 August 2025
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);
});
Request Example
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
}
}