🚀 White Paper: Fauna Architectural Overview - A distributed document-relational database delivered as a cloud API.
Download free
Fauna logo
Log InContact usStart for free
Fauna logo
Log InContact usStart for free
© 0 Fauna, Inc. All Rights Reserved.

Related posts

How Connexin delivers world-class broadband and smart city services with Fauna and CloudflareSiteGPT: Delivering a globally distributed generative AI application with Fauna, Cloudflare, and PineconeSupporting Insights.gg’s 100K global daily active users with Fauna, Cloudflare Workers, and Fly.io

Start for free

Sign up and claim your forever-free Fauna account
Sign up and get started

Stack Overflow and Glitch Notifications in Slack with Fauna

Chris Anderson|Apr 7th, 2018|


Use Case
Fauna user Nicolas Grenié has created two open source applications connecting popular services with Slack chat. If you’ve ever wanted Slack notifications when there’s online activity, his code is a good template, so I’ll link to some highlights from this post. Check out how simple Fauna makes these operations.
Nicolas Grenié agrees, remarking in chat: “Fauna is my default go-to solution for any project I am starting that involves a database.”

Stack Overflow Monitor

Stack Overflow is a popular question and answer site, making it an important place for companies to keep up with what users are asking about their products. Stack Overflow Monitor simply posts a message to a Slack channel when new questions match your search terms.
As a serverless application, it requires no operational support from you once it is up and running. No servers to upgrade or restart, just code. Installing it only requires altering one settings file, and using the serverless command to deploy functions to AWS Lambda. Once configured with Stack Overflow, Slack, and Fauna API credentials, and your chosen search terms, it will automatically update your Slack channel as long as you keep your function in place.
The entire application logic is implemented in 101 lines of JavaScript and is triggered by AWS Lambda’s cron-like task scheduler. Each time it runs, it searches Stack Overflow for recent matches, and then uses Fauna to look up the message id. If a record exists that means it’s already been posted, otherwise the message is posted to Slack and a record is created. To give you an idea how simple that code is:
              {data: question }
Because it is a simple Stack Overflow monitor, it doesn’t take advantage of Fauna’s transactional capabilities. Hardening the script for edge cases might involve tracking Slack API call success / failure state in a Fauna object as well, so that no messages are dropped.

Glitch Notifier

Glitch is a community where developers can help each other learn new skills. Answerers may only be interested in answering a narrow set of questions, so it’s nice to be alerted about activity instead of visiting the site to check for updates. Glitch Notifier is a service that alerts you in a Slack channel when new questions are available on Glitch.
Rather than a single-tenant serverless application, where you deploy an instance according to your parameters, Glitch notifier runs as a SaaS endpoint, allowing Glitch users to connect their Slack accounts and specify Glitch tags to follow. You can view the source code here, and if you sign up for a Glitch account, you can even launch your own fork of it.
Glitch Notifier uses Fauna not only to store the message ids of questions it has processed, but also to store each user’s notification preferences. Glitch questions are tagged, and users tell Glitch notifier which tags they’d like to be alerted on. Here is the query where the notifier loads all the users interested in the tags for a question.
  var users_in_db = client.query(
                  function(tag) {
                    return q.Match(q.Index("user_by_tag"), tag)
Once the user list is loaded, Glitch Notifier posts the messages to Slack using the endpoint stored with each user record.


Nicolas says helping others learn new skills is “a great way to give back to the community that welcomed me when I began.” We hope his code example above help you get started. If you’d like a code-level introduction to Fauna, here is our hello world tutorial.
Fauna costs nothing to get started with, and has a pay-as-you-go model that makes it easy to get started. Sign up today and you can create your own apps for free. Here are two more serverless starter kits: Authentication Boilerplate, and Distributed Ledger.

If you enjoyed our blog, and want to work on systems and challenges related to globally distributed systems, and serverless databases, Fauna is hiring!

Share this post

‹︁ PreviousNext ›︁

Subscribe to Fauna's newsletter

Get latest blog posts, development tips & tricks, and latest learning material delivered right to your inbox.