We ran a hackathon with members of the Programmable Banking Community to see what exciting projects teams could build using the programmable banking tech in a short space of time. In this demo, Anri and Pieter Goosen, Johan du Plessis and Shawn and Mariëtte Gradwell share the “Ziggy” Slack integration app that they built to help build better spending habits. The tech they used includes the programmable banking API, Google Cloud, Slack and Python. Check it out here!
Click here to download Anri’s presentation slide deck.
Transcript of the demo
My name is Anri Goosen. Many of you have probably met me during a Make Event. Myself and Pieter Goosen, Johan du Plessis and Shawn and Mariette Gradwell created “Ziggy” because we wanted to find a way to help us create better financial habits. One of the best ways to build a habit is using something like gamification, but you also need instant feedback if you want to build that habit. So you need to know if you’re progressing towards building your habit or if you’re sliding in building your habit. So this is what “Ziggy” is.
It’s a way for us to build financial habits using gamification and instant notifications. We did this using the Investec programmable banking platform. We used both the OpenAPI and the programmable card. We also used the Google cloud platform, Slack and Python. So Jim Rohn once said that, “Motivation is what gets you started and habit is what keeps you going,” and I think this is very applicable to our little project that we built. So how it works. First, I’m going to show you guys a quick little demo and then I’ll take you through the nitty-gritty of this system.
So like I said, Ziggy is a Slack bot. We created a little Slack channel, which has goals, and if you use normal Slack shortcuts, you can actually access Ziggy. So for instance, if you type in “Ziggy”, you’ll see there are a few commands but there’s also the main Ziggy app, which will give you options like avatars, goals, new goals, and transactions. ‘Avatar’ will list an avatar status, ‘Goals’ will give you a list of all your goals, ‘New goal’ will allow you to create a new goal, and ‘Transactions’ will show you a list of transactions that haven’t been categorised yet. This transaction categorisation is quite important, especially from a budgeting point of view. So Ziggy is built on the premise of building budgets, which we’ll get to just now. For now, let’s see how Ziggy is doing. So what we’ll see is Ziggy is currently a level one avatar. It’s got very few health points – let’s say we’ve been spending like crazy this month, but we also have quite a few XP points to help us get through.
So currently we’re on level one, which is just a little egg. He still needs to hatch. Doesn’t have any goals set. What I showed earlier was . We can see that we don’t currently have any goals, but now we can create goals. And what this allows us to do is set a savings goal or a spending goal, and then you can choose your start and end dates for your goals. Then you can also choose your spending type. Spending type will be something like a total value or a number of transactions. So total value would be a cent value. For instance, you want to add in your transport category, and the number of transactions would be if you want to limit the amount of times you go to a place like Woolworths in a month, for instance. So all your value limits, if you want to use the total value, would be in cents. So we’ll just put in an arbitrary value there.
And you can choose if you want to build a budget category based goal or a merchant based goal. So if you’re using a budget category, there’s a bunch of predefined categories, and a lot of the transactions are pre-categorised automatically by Ziggy. Or we can use merchant based, in which case you would give a merchant name and the merchant code. So for instance, if you want to go to Woolworths, you’d just find the corresponding code for Woolworths in the merchant code. But for now, we’re just going to set a budget category based goal in the entertainment category. And now we’ll see “oh my gosh, Ziggy just got some XP points for creating a goal!” That is awesome. This is your instant notification showing you what you did with Ziggy. And if we list the goals again, we now have a thread showing all the goals that we’ve made, in which case there’s one goal. We can also update the goals through here, so we can change the value, the start date, the end date, things like that. And we can also delete any goals that you want to through here.
But now, we need to make a transaction quickly, so I’m just going to make an arbitrary transaction at a merchant using a code that’s already predefined as an entertainment merchant, and we should see the transaction just got posted. And you’ll see that transaction there, which has led to Ziggy being upgraded. So we’ve got a level one Ziggy now, which is a little baby toddler. Now, we see that Ziggy is on level two and our HP took a big hit because we did actually make a transaction against a goal. Our XP also resets every time we level up, so we need to gain all that XP again to level up. If we make a transaction again against this goal, the idea here is to simulate that. We’re actually going to hit zero health points so we’re going to level down, as we see there. We just leveled down, so we’re on level one, but our HP resets to a full health bar for us so that we don’t actually struggle through and just lose all the labels at once.
As I said earlier, you can also change the category of a transaction, or you can list any transactions that might be uncategorised, but we don’t actually have transactions uncategorised at the moment. We didn’t seminate that. If we make a transaction at a different merchant – so this is the code for bike stores – yeah, I know codes for bike stores because I spend a lot of time there – then we get a transaction that shows our hobbies or sports, and we can actually change the transaction or the category for the transaction by using that little dropdown. These categories were actually predefined by us in Ziggy using the merchant JSON. So yeah, if you change it to entertainment, like we have a goal there, then you see that you actually do take a hit on your HP again. And that is it for the demo.
Now to get to the nitty-gritty technical side of things. We used Google cloud to do all of this. We set up an API gateway to handle communication between our backend and anywhere we used the Investec API or programmable banking card. So how it works essentially is you make a transaction, that transaction gets pushed to the API gateway and it gets grabbed by the add transaction cloud function. It’s going to do a bit of formatting on the transaction and then add it to our transactions collection in Firestore. Whenever a transaction is created, that creates a create event that triggers the ‘categorise new transactions’ cloud function. So that is where transactions such as bills, or groceries, transport, sport etc would be categorised. And if a transaction is categorised, it will then update the document in the Firestore collection or not if no category was found for that transaction.
That then also pushes a new transaction notification on Pub/Sub, which then goes all the way down to our Slack app in Cloud Run that then sends the Slack notification so that you get that instant notification of your transactions. So now, when a transaction is categorised, either through Slack or using the cloud function that categorises transactions, that triggers the game engine cloud function. The transaction will then be processed, which determines if your avatar takes a hit, if the avatar has to level up or down, what your XP looks like, what your HP looks like, stuff like that. And then it sends a notification via a Pub/Sub that your avatar has been updated, which then triggers a notification to Slack again. Whenever you create a new goal through Slack, it creates a document in Firestore in our goals collection, and that also then triggers the game cloud engine, which then processes goals, which again triggers the avatar notification, which again goes through the Slack app and they notify you via Slack. So there’s a lot of notification changes via this one little Pub/Sub.
Through Slack, you can create new goals, and this goes through that whole process. You can list goals, or update goals, or delete them. Again, that goes just through that whole process. Transaction, categorise – again, same process. And then with the avatar, you just get a read. So you’ll just request from the avatar collection in Firestore, and then that sends it back to you. As an additional little feature, we added a cloud scheduler, which triggers daily. We set it to about 6:00 AM in the morning and then that grabs all your transactions via the OpenAPI, adds any transactions that might be missing in the Firestore collection, processes them, and that’s where, if you have any savings goals, for instance, we look at your savings account, see if you made any deposits or withdrew anything from your savings account, see if you’ve got goals set, and then process those goals.
The challenges we encountered included creating a Slack bot, firstly. None of us have any experience writing Slack bots, but Johan was a trooper and he created the entire Slack bot for us. But one of the big problems we ran into was that the Slack bot has a three-second limit and Google cloud functions written in Python have a very long cold start time, so sometimes there would be some timeouts happening there. And then processing transactions with the different formats – this is just the disconnect between the OpenAPI and the programmable card that Wayne was also talking about a little bit earlier. It was quite interesting trying to figure out if you already have transactions in the database, how you grab it via the OpenAPI and try to get those things to match up. And then, because this is a hackathon, we did not get enough sleep. I just got a request from Pieter here to quickly show you guys the other avatars that we have.
I was going to ask. Bit of a spoiler alert.
So yeah, in that little demo I just showed you actually levels one and two, which is the egg and then you get little toddler Ziggy, but we also have little kiddo Ziggy, which loves to play with balls, and then we have the teenager Ziggy, which is quite a cool dude roller skating around, and then we get to superstar Ziggy when you hit level five.
And who did the drawings, Anri?
Mariette did all the drawings for us and did all the concept art for us.
Audience member: (14:27)
Sorry, I’m looking to put a hand up but I can’t find it. You were speaking about a three-second delay that sometimes ran out. We found some delays at times as well, and I was wondering whether it was GCP, whether that was on the Investec side where the call to a GCP took longer, and we weren’t able to figure out which part it was. You should find the three seconds should be more than enough for a transaction going out to GCP and coming back with a result.
No, we just found it to be very inconsistent because even when we tested earlier, it took considerably long. And when we initially did this, in a second it returned via Investec. So, very inconsistent.
Yeah, the timeout we had problems was between the Slack bot and Google cloud functions where any Google cloud function that was written in Python takes very long when it has to cold start. If it’s already run once or twice in the day, it’s actually a lot faster.
Audience member: (15:48)
Oh, so are you saying that’s your initial call and that generally takes a bit longer for the initial call?
Audience member: (15:54)
Okay, like Dean said, it was inconsistent. Sometimes it would be sub-second, other times it would be slightly longer, and we’d have to sit there and wait, and wait for the screen to refresh. Even on the Firestore side, you generally see updates happening immediately, it would sometimes take a lot longer, but it was inconsistent and we couldn’t place it on … we couldn’t say it was definitely this component or that component.
Cool. So the next steps we envision for our little project is just finalising and wrapping up the savings goals using the Investec API. We were in a bit of a rush and haven’t polished it nicely just yet. And then anyone who’s had the repo would have seen that this is one big pain to install and get running for yourself, so we would love to make Ziggy a hell of a lot easier to install. Then we also want to expand Ziggy for multiple users, so we can create a community of habit building. We also want to create quests that you can create. So the idea is that you can create individual quests and you can also run monthly community quests where anyone that does good against some goals makes progress against the community quest, but whenever someone slacks off in their goals, the whole community feels it, which would obviously be offset by people doing good. And that is what we envision for Ziggy.
If you want to get involved, you can find most of us on the OfferZen Slack Community. I’m @AnriGoosen, you guys can also speak to me at the Make Event and find me in most of the channels. Then we also have Pieter G, Shawn Gradwell, and Johan du Plessis. All the code and installation instructions can be found on our repo. And if anyone wants to have a little look at our Investec video, there’s a link to that as well. Any questions?
Get involved in the Programmable Banking Community
If you want to see more from what the community has been up to, you can: