Hello! What I’m saying is going to be very ambitious and probably requires alot of time to nail correctly so just a word of warning!
I am trying to see if there is anyway to use some API (in or out of ROBLOX) to send a message to the user’s INBOX (not in-game chat, not the friends chat.) I am trying to figure and lay my options out to see if I can do this in ROBLOX alone, or will I have to use a third party API call, preferably one I made myself using python and/or JavaScript.
I have a WIP that I have that used HttpService and MessagingService. (with the help of chatgpt :P)
I’m almost confident we went the wrong way with this one, but I’m not certain as I am not a big fan of HttpService.
local HttpService = game:GetService('HttpService')
local MessagingService = game:GetService('MessagingService')
local function handleMessageRequest(reqBody)
local userId = reqBody.userId
-- Send a message to the user's inbox based on the UserId
local success, message = pcall(function()
local recipient = 'rbxuser://' .. userId
local subject = 'Message from Roblox'
local body = 'This is a test message from your Roblox game.'
MessagingService:SendMessageAsync(recipient, subject, body)
end)
if success then
return 'Message sent successfully!'
else
return 'Error sending the message: ' .. message
end
end
-- Create an HTTP endpoint within the same script
local function handleHttpRequest(req, res)
if req.Method == 'POST' and req.Path == '/send-message' then
local success, request = pcall(function()
return HttpService:JSONDecode(req.Body)
end)
if success and request.userId then
res.Body = handleMessageRequest(request)
res.StatusCode = 200
else
res.StatusCode = 400
end
else
res.StatusCode = 404
end
res:Send()
end
-- Start the HTTP server
local server = game:GetService('HttpService'):CreateServer('127.0.0.1', 3000, handleHttpRequest) -- error happens here lol
server:Start()
If you’re able to understand what I’m saying and are able to help out, it would be really nice!
As always, any help possible is very appreciated!