Nice thing about holidays is there is more than usual spare time to tinker with things. I’ve been thinking adding a feedback form for the blog but that would require a backend to process the form. Running a server for such a small thing doesn’t really make any sense especially when all other content is static. NOTE: If you are interested, there is prequel to this post on how to build a website with static-site generator and AWS Amplify.

So I browsed Github for suitable serverless solution for processing feedback form. At first I was thinking emailing forms using SES but quickly dropped that idea in favour of posting to Slack. There are already more than enough emails and integration with webservice would be easier than sending email.

From Github I found a project that wasn’t quite doing what I wanted but was simple enough to be modified for my purposes. Google reCAPTCHA integration was about the only thing that was left from the original code in the end but it was easier to get started with working example.

I rewrote Cloudformation template in SAM to save some trouble of manually wiring API Gateway, Lambda and IAM together. I also removed much of the original Lambda code and replaced email sending with posting to Slack via a webhook.

I was hoping to find some nice feedback form for Jekyll but ended up writing it from scratch myself. It works but I wouldn’t take that as an example how to write HTML. Form is now on /about -page of this blog.

Then everything was ready for the first feedback to be submited. I filled the form and clicked “Submit”. Look and behold, there was a message on Slack!

Feel free to try it out and send me a message.

To be honest getting the first message through took some rounds of debugging but that was the learning part of the exercise. One little odd detail I learned from SAM -templates was how to get rid of API stage called “Stage”. I had defined my API stage should be called “prod” but no matter what I did there was always also another stage called “Stage”. The Solution turned out to be OpenApiVersion property for AWS::Serverless::Api. If you are interested, the history of issue is documented here.

    Type: AWS::Serverless::Api
      Name: ContactUs API
      StageName: !Ref APIStage
      OpenApiVersion: '2.0'
      EndpointConfiguration: EDGE

Code for the project, including a short README and sample HTML-form, is available in Github.