I got this question in my comments.
Now, this usually means that something went wrong in the webhook code.
Here is a process for fixing this issue:
1 Make sure you are using API v2
2 Set up ngrok on your computer
I have written about this before. Being able to use ngrok will significantly speed up your webhook development.
3 Copy the JSON of the fulfillment request from the Dialogflow simulator
Issue the query inside the Dialogflow simulator. Once you do that, you should click on the Diagnostic Info button and take a look at the fulfillment request.
4 Use Postman app to issue the request to your local webhook
Since you now have ngrok set up, you can use the Postman app to send the JSON to your webhook.
5 Step through your code
When you do this correctly, you will be able to step through the code on your local machine, and figure out what is causing the 500 Internal Server Error.
Want to learn about webhooks in depth?
In my Dialogflow Webhooks course, I explain how to set up ngrok and use it to debug PHP code.