- August 13, 2017
- 1 min read
Updates To Foodtruck Bot
I made few enhancements over the weekend to seattle food truck bot. If you haven't read my previous post on seattle food truck bot I suggest you head over to this link
- Monday - Friday update a channel in slack with food trucks available for a specific number of locations
- T-Mobile has multiple locations (Factoria, Bothell etc.) where we get food trucks for lunch. By automatically updating trucks for these locations we no longer need someone asking the bot to show trucks at these locations daily, Mon-Friday
How this is Implemented
- Pretty simple, I found a golang package that implements cron spec parser and a job runner. For more information see
- Created a function that takes collection of locations as input and return a formatted message that can be posted to Slack channel. Using the Cron scheduler functionality in the cron package mentioned above, scheduled execution of this function at 8AM Mon-Fri and post message to slack channel configured. See sample code below
if len(locations) > 0 && channel != "" {
fmt.Println("Creating a new instance of Cron Scheduler")
c = cron.New()
c.AddFunc("0 0 08 * * mon-fri", func() {
fmt.Println("Executing func in Cron")
message, err := showTrucksForLocations(locations)
if err != nil {
fmt.Println("Failed to get trucks for locations")
} else {
log.Println("Message : ", message)
responseHandler(channel, message)
}
})
//Start the Cron
fmt.Println("Starting Cron")
c.Start()
}- Screenshot below shows slack message posted to "#food" channel by the BOT for T-Mobile Factoria and Bothell locations.
- Format time as AM/PM
- Previously when the bot shows trucks at a specified location it use to display time in 24hr format. This is now changed to show time as AM/PM. See example in screenshot below
Deployment
If you are deploying this bot in a docker container, when you run the container LOCATION_IDS and CHANNEL environment variables need to be set as shown in example below
docker run -d -e SLACK_TOKEN=<replace with token> -e LOCATION_IDS=<replace with comma delimited location ids you are interested> -e CHANNEL=<replace with slack channel> rprakashg/foodtruck-slack-botIf you are deploying this bot in heroku as I have done for our team, you can simply configure CHANNEL and LOCATION_IDS in heroku for the app under Config Variables in Settings tab as shown in screenshot below
Cheers,
Ram
Related Posts
RAM GOPINATHAN
August 12, 2026
Building Kubernetes-Style APIs: A Practical Walkthrough
Kubernetes real innovation is the declarative, self-healing API pattern. This post builds that pattern from scratch: an OpenAPI-first server, a Postgres-backed store instead of etcd, and a clean service/store split that keeps business logic out of the database
RAM GOPINATHAN
February 28, 2026
Automating post install configurations with cloud-init for Red Hat Enterprise Linux deployments on baremetal environments
Stop configuring servers by hand. Here's how cloud-init brings cloud-level automation to your physical infrastructure.
RAM GOPINATHAN
January 22, 2026
PODMAN TIPS: Implementing init container pattern for containers running on PODMAN
If you’ve worked with Kubernetes, you’re probably familiar with init containers—containers that run before the main application and are typically used for setup or initialization tasks. In this post,…