This Gist describes how to use Google App Scripts to post a message on Discord whenever a Google Form is submitted.
- Create a Discord Webhook.
- Create a Google Form.
- Open the Google App Scripts Editor
In the top right corner of the Google Form, click the vertical menu bar (⋮), and select "Script editor". - Create a function that does the following:
- Loads the last response in the form.
- Constructs an embeded message to send to Discord.
- Sends the message to the Discord Webhook.
You can refer to this example for how to do this.
- Test your code
Save your file and then press the "▷ Run" button to test your code.
Make sure your form has at least 1 response. This test will always pull the last submitted response.
If the request to the webhook returns a response that says{"embeds": ["0"]}
, then that means the payload was not formatted correctly. Unforunately this can be difficult to debug. Please refer this guide or the official Discord documentation. - Add a Trigger
Lastly, we need to add a trigger so this code is excecuted when a new form is submitted.
On the left pane, click the "Triggers" icon that looks like an alarm clock, then press "Add Trigger".
Make sure "Select event type" is set to "On form submit".
Your Google Form should now be connected to your Discord channel 🎉
The message should look something like this: