Creating a simple AWS Cost Explorer chatbot with CSML

Francois Falala-Sechet
Published in
5 min readJan 14, 2020

AWS Cost Explorer is a very important tool in the AWS universe to make sure that you stay on budget. It helps you find out what the biggest cost drivers are in your infrastructure, decide about optimization strategies, monitor improvements made over your infrastructure… With Cost Explorer, you can quickly detect variations in your cost structure — for example, you may want to try different autoscaling strategies and monitor their impact on your billing.

However, Cost Explorer is often overlooked by AWS users as it is not directly related to creating value (building your application or service), and even experienced customers often forget to check their costs regularly on the Cost Explorer console.

On the other side, chatbots are an easy and friendly way to retrieve information in a familiar chat interface. Especially, ChatOps are a trend with a lot of monitoring and alerting tools integrated into messaging platforms such as Slack.

In this tutorial, we will go over how to create a simple chatbot that gathers a first level of information from AWS Cost Explorer. This tutorial assumes that you have an AWS account and some basic knowledge of IAM user rights administration, as well as some understanding of some very basic code principles in order to be able to read the CSML flows — don’t worry, it is quite self-explanatory. The CSML documentation is available on for reference.

You will also need a free account in the CSML Studio and perhaps as well a Slack account to deploy this bot!

Photo by Arseny Togulev on Unsplash

The conversation

The first thing I do when thinking about a small chatbot like this is map out the conversation in the concisest form possible. Pen and paper will do at this point!

We would like to be able to do two things in our bot:

  • retrieve past costs for monitoring
  • find out a forecast of future projected costs for anticipating

We will also need to be able to know what is the timeframe (start/end date) for the cost report. As we are looking for something quick/simple, let’s only use prepared dates: last month, today, year to date, next month