Speeding Up Software Development with ChatGPT 4.0: A Case Study on Building a Slack App

Siddharth Ram
7 min readJun 19, 2023

--

I don’t write code regularly any longer. As is always the case, lack of practice always results in attrition of skills. So much has changed with the advent of Generative AI. I decided a long weekend and a desire to learn how they can help is the perfect time to tackle a problem.

A Slack App: Employee recognition tool

The problem I decided to tackle was an employee recognition tool. We did a trial of a commercial tool that allows an employee to recognize another by giving them a slack emoji, and then keeps a leaderboard. It has a few more bells and whistles, and employees really liked it. But the cost for what I thought was a very simple tool was very high. So I asked myself ‘How hard can it really be?’

Larry Wall believes that the principal attributes of a good programmer are impatience, hubris and laziness. My hubris had me believing that I could have it done over a weekend. And Larry did not have access to ChatGPT 4.0 when he wrote those principles.

So I rolled up my sleeves and got to work. I sketched a quick diagram: Lambda functions, Dynamo for storage, slack is the UI. Yeah, I can do that.

My Takeway:

ChatGPT 4.0 is an absolute marvel. I managed to have most of it working in about 6 hours of work, with a huge assist from ChatGPT. All the hype you hear about it? Absolutely justified. This is an absolute gamechanger. I estimate that it would have taken me two-three times as long to do it without ChatGPT, so a 50–75% efficiency improvement is my estimated ballpark figure. I’m guessing my rustiness upped the improvement figure, and had I been coding more regularly, The $20 I pay for ChatGPT is the easiest of all my spend to justify. I easily get 20x back on it.

The tool is now up and running, and delighting my co-workers. ( I will clean up the code a little and move it to a public github repo).

Here is my estimate for how much time it would have taken me, with and without ChatGPT. Yeah, I literally finished in a third of the time it would have taken me without help.

Time savings using ChatGPT

Usage Modalities

The primary value I got from it was

  1. Scaffolding. Getting started was much easier with an assist from ChatGPT, in a way that searches could never have helped. I could give it detailed information ‘I want to store data in DynamoDB, set up lambda with the following functions, and use SNS. Generate a SAM template for me’. Ok, there, I just saved myself an hour.
  2. It is so much better than reading documentation. It gives me precisely the answers I am looking for, based on my prompt. I ask questions and I get detailed answers on how to proceed, specific to my scenario. Beats the pants off of reading documentation and finding relevant portions..
  3. It understands and makes smart recommendations to solve specific problems I was running into. I’d run into a bug. ChatGPT would make recommendations on how to solve it. Some were ‘duh’ kinds of solve — a typo that I had missed. Others required more investigation and understanding. Both of them were boosted tremendously by ChatGPT. My fam, long used to my loud complaints while coding, were treated to my gasps of astonishment as ChatGPT made my tasks easy.
  4. Code reviews. Before I tested the code, I asked ChatGPT to review the code. It found errors that would have taken me a while to figure out.
  5. Of course, I took its help in writing this blog. While I tried to ask it to create a blog post based on my experience, I found it did not do a great job. Most of this is written by me, polished with suggestions from ChatGPT

Writing down the requirements

Here is my quick writeup on requirements:

  • As an employee, I can recognize someone by joining a slack channel and using a rubber duckie emoji as a thank you (inspiration: https://youtu.be/acBixR_JRuM)
  • As an employee, I can see see the leaderboard

Thats it.

2. The Development Process

The development process involved several steps, including setting up AWS Lambda functions, configuring an API Gateway, and integrating with Slack.

1. Setting up the project with SAM (Serverless Application Model)

I knew I wanted to use AWS Lambda for compute and DynamoDB as storage. Message notifications would be done using SNS. So rather than build the template.yaml by hand, I asked ChatGPT to generate the template for me. Giving it a prompt with clear instructions gave me this template that worked correctly. (The SNS topic was added later when I realized that I needed it to get a slack slash command to work)

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: An AWS Serverless Application.

Resources:
PublishLeaderBoard:
Type: AWS::SNS::Topic

GiveDuckieFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: giveDuckie/app.giveDuckie
Runtime: nodejs16.x
Events:
giveDuckie:
Type: Api
Properties:
Path: /giveDuckie
Method: post

GetLeaderboardFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: getLeaderboard/app.getLeaderboard
Runtime: nodejs16.x
Policies:
- Statement:
- Effect: Allow
Action: sns:Publish
Resource: !Ref PublishLeaderBoard
Events:
getLeaderboard:
Type: Api
Properties:
Path: /getLeaderboard
Method: post
SnsTopic:
Type: SNS
Properties:
Topic: !Ref PublishLeaderBoard

MyDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: duckies
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
  1. Getting Slack reactions up and running

I had ChatGPT explain to me how I can get events based on reactions in slack. In particular, I wanted to be able to react to the ‘rubber-duck’ emoji. This is where it really shines — it was able to build instructions for me telling me how I should approach it, including configuring slack as well as backend code for how I would react to it. I took the template it generated which was 60% complete, including saving data to Dynamo.

  1. Debugging

Note the loop below — for (const user of users). I had written the code using forEach() — without understanding that promises returned get ignored by it. ChatGPT pointed out this problem, and recommended that I change my code. I was thinking — if I had not gotten this feedback, how long would it have taken me to realize my error? North of an hour, I suspect.

async function reactionAdded(msg) {
const sender = msg.event.user;
const reaction = msg.event.reaction;
const channel = msg.event.item.channel;
const recipient = msg.event.item_user;
const ts = msg.event.item.ts;
// Check if the reaction is the rubberduckie emoji and the channel is the specific channel
if (reaction === 'rubber-duck' && channel === CHANNEL_ID) {
const users = await idsFromHistory(ts);
for (const user of users ) {
const updateRecipientParams = {
TableName: 'duckies',
Key: { userId: { S: user.receiver }},
UpdateExpression: 'ADD totalReceived :inc SET username = :username',
ExpressionAttributeValues: {
':inc': { N: '1'},
':username': {S: user.recipientUserName}
},
ReturnValues: 'UPDATED_NEW'
};
await updateStore (updateRecipientParams);
const senderUserName = await getUserName(sender);

const updateSenderParams = {
TableName: 'duckies',
Key: { userId: { S: sender } },
UpdateExpression: 'ADD totalSent :inc SET username = :username',
ExpressionAttributeValues: {
':inc': { N: '1' },
':username': {S: senderUserName}
},
ReturnValues: 'UPDATED_NEW'
};
await updateStore(updateSenderParams);
const duckies = await getDuckieCount(user.receiver);
const text = "User " + user.recipientUserName + " now has " + duckies + " duckies!"
await postMessageToSlack(CHANNEL_ID, text);
}

return {
statusCode: 200,
body: ' added count'
};
}
}

This is one of several examples where I was saved a lot of time by knowing exactly what I should investigate. Another example was using slack slash commands. I wrote a /leaderboard command, not realizing that slack has a strict 3 second policy on the response to the command — and that I have to respond right away, and post an update later given that I need to fetch and process data from DynamoDB before I can post the leaderboard. Slack just gave me a generic “error_dispatch” message. ChatGPT suggested four reasons this could be happening, and I realized that I need to queue a message (using SNS) and post a message when I was done processing. IMO, this is one of the best reasons to use ChatGPT — as a debugging buddy.

Understanding Dynamo DB

I have not used Dynamo previously, and this felt like a good use case for a key value store. So I had ChatGPT write up how Dynamo should be used in my specific use case. It gave clear instructions, with example code. This made it easy to write the commands to update DynamoDB

Retrospective

Throughout the development process, ChatGPT was an invaluable resource. It provided immediate responses to questions, saving the time that would have been spent searching for solutions online. It also provided detailed explanations and examples, helping to deepen understanding of the concepts involved. This experience is vastly superior to the search experience — I did not used stackoverflow or duckduckgo searches for problems at all.

I do worry if I will become intellectually lazy using ChatGPT. There is always value in struggles — that is how we improve and become better programmers. Having problems analyzed and presented to you with clear instructions reduces development time — and probably how well we have understood problems.

Having said this, there is no going back. Tools like GitHub CoPilot and ChatGPT are definitely going to make us develop faster, and hopefully make better programmers of us.

Table Of Contents

--

--