Hello
I am a game developer on Roblox and I have a game and I want to create an app that receives webhook messages from my game if someone purchases something or wins certain challenges.
Can I create this app for free or do I have to pay a fee to receive Webhook messages?
I am sending webhook messages to the game server on Discord using a URL. Can I do this on the application I am creating?
Note that my game is not big or popular and I receive very few webhook messages. Can I get a small free storage space or do I have to pay for data storage?
You can create HTML endpoints in a free app. You’ll have limits, of course, on how much data you can store in your data tables, how much traffic you can have, etc, but if it’s not much you should be fine.
hello
Thank you for replying to my message. You answered my question about Anvil Pricing Plans, but has anyone before me linked their Roblox game with an app they created on Anvil? I don’t have extensive knowledge in creating apps. Is there a close example of what I want to do so I can learn how to do it?
On Roblox we can enable studio access to API services. Can we do this on Anvil where I can receive webhook messages without publishing the app for testing purposes? Is there another way I can use to check if messages are received during the app creation process?
Endpoint requirements as per Roblox requirements
Set up webhook URLs
You can set up a custom HTTP service endpoint as your webhook URL, provided it fulfills the following requirements:
1 It must be publicly accessible for handling requests.
2 It can handle POST requests.
3 It can respond to the request with a 2XX response within 5 seconds.
4 It can handle HTTPS requests.
When your endpoint receives a POST request, it must be able to:
Extract the details required about the notification from the body of the POST message.
Read the body of the POST message with the generic details on the notification and specific details related to the event type on the notification.
Hello jshaffstall
Thank you for directing me to this topic. It helped me understand how to deal with HTTP on the Anvil website, but unfortunately the code
@anvil.server.http_endpoint('/tasks')
def get_tasks(**q):
return [{'title': task['title'], 'done': task['done']}
for task in app_tables.tasks.search()]
When I use curl I don’t get the same result mentioned in the topic.
$ curl https://my-todo-list.anvil.app/_/api/tasks
[{"done":true,"title":"Wash the car"},{"done":true,"title":"Do the dishes"}]
So I stopped here after several failed attempts, the details of which I cannot mention because that would make the post very long.
I don’t need to return anything to Roblox. All I need is this:
When I convert the words I want to send from the Lua code in Roblox from text to JSON, here in Anvil, I want to do the opposite. I convert them from JSON to text. If I have to write anything in the code to process the data before converting, that’s fine. I want to get the text I sent.
You don’t say what results you did get, so it’s impossible for us to say where you might have gone wrong. Your code looks fine from what I can see.
Providing a clone link and specifically saying what’s not working also helps forum members play with the app and see what you might be doing wrong.
So you have these tasks:
Have Roblox code call your endpoint
Parse the data sent
Do something based on that data
Take those one at a time. Have an HTTP endpoint that prints something out, and then call it. Check your Anvil app logs to see if you can see that session where it prints out the message. If you can, that means you can call the endpoint from Roblox. If you can’t, there’s no sense trying to do the other tasks yet.
Thank you jshaffstall you have been patient with me i was able to get what i wanted thanks to your help
Anyone who wants to receive a text message using a webhook from their game on Roblox can use this code. It’s very simple. It receives a single text sentence. I don’t need more than this to create an application for my game. You can contact me here if you want help with Roblox Studio.
import anvil.server
@anvil.server.route("/receive_json", methods=['POST'])
def handle_json_data():
# Access data sent in JSON format
request_body = anvil.server.request.body_json
if request_body:
# You can now treat request_body as a Python dictionary.
name = request_body.get('name')
print(f"Data received: Name is___ {name}")
return {"status": "success", "message": "Data received successfully"}
else:
# Handling cases where data is not in JSON format
return {"status": "error", "message": "No valid JSON data received"}, 400