To use the code in code.gs you must have a Google form setup then go to the response Google sheet associated with it. Once on the sheet you can go to “Tools->script editor…”. A new tab should open with the script editor and some default code in the “Code.gs” tab should be visible. Remove the default code and replace it with the above and save it as whatever project name you wish. Next you need to run the initialize function by going to “Run” in the menu and choosing “initialize” it will ask you to approve and allow the script to run – do so.
To get this function with Slack you have to have to use your Slack user or create a Bot and set a token that you can use as part of your payload to authenticate to your Slack team space (NOTE the “as_user” field can be set to “true” s that the either you or the named bot show up as the entity posting the message in the channel if you leave this “false” it just posts as “bot”). You can do this by going to you account settings or your integration settings if you wish to use the Bot. Next you need to decide which channel to use or create a new one and set it in the payload (NOTE If you are using a specific bot to post the message they have to be a member of this new channel otherwise it will not be able to post messages).
Once you have repleaced the token and channel in your script and it has been initialized by running the initialize function in the editor you are good to go. You can test that the settings are correct and will post to your slack channel by selecting the TestSlack function from the dropdown and pushin the play/run button – it should add a message in your slack channel “testing my stuff”. You can ten test by submitting to your Google form and seeing the results in your slack channel.