Image courtesy of Adobe Stock

Leveraging artificial intelligence (AI) tools can significantly expedite the business analysis process. By utilising advanced AI models like GPT, analysts can quickly analyse problem statements, define high-level features and objectives, and generate epics and user stories. AI tools can streamline requirements gathering and save time and effort while enabling structured and organised analysis.

As part of an exploratory exercise, we tried to find out how OpenAI’s GPT can be leveraged to kickstart the business analysis process and do rapid requirement gathering.

You can read about the methods and tools used for the experimentation.

Every business analysis process starts with identifying a problem statement and then listing out the high-level business goals or requirements. With the help of OpenAI chat completion APIs in Python, we could engage in an interactive conversation, and quickly generate ideas and requirements to kickstart the analysis process.

Generating Epics and Stories with Prompt Engineering

Epics and stories are key components of breaking down complex projects into manageable units. During the initial analysis phase, epics are identified from high-level features, which are further broken down into stories. Subsequently, acceptance criteria is written at the story level, telling us specific details to know when we are done.

We used GPT to identify three high-level business objectives for a time-tracking application.

The problem statement was given as a prompt:

Identify the top 3 features of a time tracking app for employees to enter work
hours against projects so reports can be generated regarding billable hours
and then invoices can be created for the billable hours.

GPT identified the following three high-level features:

1. Time Entry and Tracking: The app should have an easy-to-use interface that
allows employees to enter their work hours quickly and accurately. The app
should also have a timer feature that enables employees to track the time they
spend on each project.

2. Reporting: The app should be able to generate detailed reports on the time
spent on each project and task, including billable and non-billable hours, and
total time spent. These reports should be customisable, allowing for filtering
and sorting based on different criteria.

3. Invoicing: The app should be able to create invoices for the billable hours
worked on each project. The invoices should be customisable and allow for
different billing rates and payment terms.

We used these high-level features to generate epics and stories.

Customising AI for Consistent Analysis

Business analysts will follow a defined structure and format while writing an epic or a story. Although the GPT model knows what an epic or user story is, we wanted to provide our own definition and format to ensure consistent style in story generation. A technique we found helpful was to build a structure detailing how we wanted our epics, stories, and acceptance criteria to be written. This ensures that the generated stories align with the desired writing style and format.

This structure and format was defined in JSON format as seen below:

epic_story_ac_structure = {
"epic": {
"definition": "An epic is a large body of work that can be broken down into a number of smaller user stories.",
"format": {
"structure": "<Epic-Heading> : <Description>",
"example": "Login : Login for new visitors"
},
"example": "The epic for a search functionality in a music app can be written as '''The new search functionality will allow users to narrow down their search and offer suggestions to help them find the music they want to listen to instantly.'''"
},
"story": {
"Definition": "A user story is a small, self-contained unit of development work designed to accomplish a specific goal within a product. It provides an informal, natural language description of a feature of the software or product from the end-user perspective.",
"template": "As a < type of user >, I want < some goal > so that < some reason >.",
"format": {
"structure": "<User-Story-Number> - <User-Story-Heading> : <User-Story>",
"example": "GT-Recruit-101 - Post resume to website\
A user can post her resume to the web site so employers can be informed \
about the work details about the user."
},
"example": "A few real examples of user stories that describe the desired functionality in an early version of the Scrum Alliance website are below: \
1. As a site member, I can fill out an application to become a Certified Scrum Trainer so that I can teach Certified Scrum Master and Certified Scrum Product Owner courses and certify others.\
2. As a trainer, I want my profile to list my upcoming classes and include a link to a detailed page about each so that prospective attendees can find my courses.\
3. As a site visitor, I can access old news that is no longer on the home page, so I can access things I remember from the past or that others mention to me.\
4. As a site visitor, I can see a list of all upcoming “Certification Courses” and can page through them if there are a lot, so I can choose the best course for me."
},
"acceptance-criteria": {
"definition": "A set of statements, each with a clear pass/fail result, that specify both functional and non-functional requirements and are applicable at the feature and story levels. Acceptance criteria constitute our 'Definition of Done'.",
"template": "Given <what all are the given conditions>, when <a particular action taken>, then <the result of that action>.",
"format": {
"structure": "<List of acceptance criterias>",
"example": "Few real examples of acceptance criterias for a user story '''As a user, I want to be able to recover the password to my account so that I can access it in case I forget it. ''' are below:\
1. Given The user is logged out When the user navigates to the login page, they see the "forgot password' option.\
2. Given The user navigates to the login page When the user selects the "forgot password' option and enters a valid email to receive a link for password recovery, the system sends the link to the entered email.\
3. Given The user receives the link via the email When The user navigates through the link received in the email Then The system enables the user to set a new password"
}
}
}

We defined a prompt for generating epics and utilised OpenAI’s chat completion endpoint to generate the list of epics.

The prompt (variable: `epic_prompt`) was provided with:

  1. `The above predefined structure (variable: `epic_story_ac_structure`)
  2. The 3 high level feature requirements (variable: `product_high_level_requirement`)
epic_prompt = f"""

Epic = {epic_story_ac_structure["epic"]["definition"]}

Example for an epic : {epic_story_ac_structure["epic"]["example"]}

Your task is to perform the following actions:
1. Analyse each of the features listed to determine the various high-level epics.
2. List each epic.
3. Describe each epic in a few sentences.

Use the following format:
Feature: <Feature Heading>
Feature Summary: <Feature Description>
Epics: List of Epics in the Format: '''epic_story_ac_structure["epic"]["format"]["structure"]'''>. Format example: '''{epic_story_ac_structure["epic"]["format"]["example"]}'''

Text: <{product_high_level_requirement}>
"""
epics_response = get_completion(epic_prompt)

The ‘get_completion’ method is shown below; it talks to OpenAI’s chat completion endpoint.

Note that we set the ‘temperature’ to 0, which is the degree of randomness of the model’s output. This ensured consistent results on multiple runs.

def get_completion(prompt, model="gpt-3.5-turbo"):
messages = [{"role": "user", "content": prompt}]
response = openai.ChatCompletion.create(
model=model,
messages=messages,
temperature=0,
)
return response.choices[0].message["content"]

The response contained a list of epics for each of the three features.

E.g., for the feature “Time Entry and Tracking”, two high-level epics were identified along with the description.

Epic List:
Feature: Time Entry and Tracking
Feature Summary: The app should allow employees to enter their work hours quickly and accurately and track the time spent on each project.
Epics:
Time Entry: The app should have an interface that allows employees to enter their work hours quickly and accurately.
Time Tracking: The app should have a timer feature that enables employees to track the time they spend on each project.

Feature: Reporting.
Feature Summary: The app should be able to generate detailed reports on the time spent on each project and task, including billable and non-billable hours and total time spent.
Epics:
Report Generation: The app should be able to generate detailed reports on the time spent on each project and task, including billable and non-billable hours and total time spent.
Customisation: The reports should be customisable, allowing for filtering and sorting based on different criteria.

Feature: Invoicing.
Feature Summary: The app should be able to create invoices for the billable hours worked on each project, with customisable billing rates and payment terms.
Epics:
Invoice Creation: The app should be able to create invoices for the billable hours worked on each project.
Customisation: The invoices should be customisable, allowing for different billing rates and payment terms.

The response containing the list of epics was further passed into the prompts for story, UI mockup and acceptance criteria generation. Combining some of these prompts into a single prompt does not give good results; the details of the stories get truncated and expected details get omitted. It took some trial and error to arrive at these prompts.

At a high level, the steps involved in both prompts are:

  1. Analyse each of the epics to identify the various user stories.
  2. List each epic using the format:
    <Feature>
    <Epic-Heading>
  3. Analyse the stories within each epic and generate user stories using the user story format.
  4. Assign a ‘User-Story-Number’ and a ‘User-Story-Heading’ for each user story.
  5. Suggest a detailed UI mockup for each user story along with validation logic for each UI element.
  6. List the acceptance criteria for each user story.

The story prompt:

story_prompt = f"""
User-Story = {epic_story_ac_structure["story"]["definition"]}

When writing a user-story, follow the standard format mentioned with text delimited by triple
quotes.
'''{epic_story_ac_structure["story"]["template"]}'''

User-Story-Number = '''{project_abb}-<Project short name for 'Epic-Heading'>-<Story-Number>'''
Example for a user-story : {epic_story_ac_structure["story"]["example"]}

Your task is to perform the following actions:
1. Analyse each epic and break it down further into various user stories.
2. List each epic in the below format:
<Feature>
<Epic-Heading>
3. List out detailed user stories in each of the epics in the below format:
<User-Story-Number> - <5 worded title for the user story> : <User-Story>

Text: <{epics_response}>
"""
story_response = get_completion(story_prompt)

We wrote a Python method utilising OpenAI to generate product and feature names’ abbreviations. These abbreviations were then used to assign a User-Story-Number to each story, such as TSC-TET-001, providing a concise representation.

The prompt generated 12 stories from the epics.

User Story List:
Feature: Time Entry and Tracking
Epic-Heading: Time Entry
TSC-TET-001: Quick and Accurate Time Entry: As an employee, I want to be able to enter my work hours quickly and accurately so that I can focus on my work.
TSC-TET-002: Project Selection As an employee, I want to be able to select the project I am working on while entering my time so that my time is accurately tracked.

Epic-Heading: Time Tracking
TSC-TT-001: Project Timer As an employee, I want to be able to start and stop a timer for each project I am working on so that I can accurately track my time.
TSC-TT-002: Time Summary: As an employee, I want to be able to view a summary of the time I have spent on each project so that I can manage my time effectively.

Feature: Reporting
Epic-Heading: Report Generation
TSC-RG-001: Detailed Time Report: As a manager, I want to be able to generate a detailed report on the time spent on each project and task so that I can monitor progress and identify areas for improvement.
TSC-RG-002: Billable and Non-Billable Hours: As a manager, I want to be able to generate a report that shows the billable and non-billable hours for each project so that I can accurately bill clients.

Epic-Heading: Customisation
TSC-CU-001: Report Customisation: As a manager, I want to be able to customise the reports based on different criteria, such as project, employee, and date range, so that I can get the information I need.
TSC-CU-002: Invoice Customisation: As an accountant, I want to be able to customise the invoices with different billing rates and payment terms so that they are accurate and professional.

Feature: Invoicing
Epic-Heading: Invoice Creation
TSC-IC-001: Billable Hours Calculation: As an accountant, I want the app to automatically calculate the billable hours for each project so that I can create accurate invoices.
TSC-IC-002: Invoice Preview As an accountant, I want to be able to preview the invoice before sending it to the client so that I can ensure accuracy.

Epic-Heading: Customisation
TSC-CU-003: Payment Terms As an accountant, I want to be able to customise the payment terms for each invoice so that they are appropriate for each client.
TSC-CU-004: Invoice Branding: As a business owner, I want to be able to customise the branding on the invoices so that they reflect my company's image.

If you analyse the stories, you would realize that more stories are needed for a basic time-tracking application to work seamlessly e.g., editing of the timesheets. Some stories may not be required e.g., TSC-CU-002 — Invoice Customisation, TSC-CU-004 -Invoice Branding, etc.

The response with the story list was given to the UI mockup prompt and then the UI mockup response was further passed into the acceptance criteria prompt to generate acceptance criteria for all 12 stories.

Below is one of the stories with acceptance criteria and UI mockup details for capturing the time spent on a project.

Feature-Heading: Time Entry and Tracking
Epic-Heading: Time Entry
TSC-TET-001: Quick and Accurate Time Entry
User-Story: As an employee, I want to be able to enter my work hours quickly and accurately so
that I can focus on my work.

UI Mockup:
A form with fields for date, project, task, start time, end time, and notes.
A button to submit the time entry.

Validations:
The date field should only accept valid dates.
The project field should be a drop-down list of available projects.
The task field should be a drop-down list of available tasks for the selected project.
The start time and end time fields should only accept valid times.
The end time should be greater than the start time.
The notes field should have a character limit.

Acceptance Criteria:
1. Given the user is on the time entry page, when the user fills in all the required fields and
clicks on the submit button, then the time entry should be saved successfully.
2. Given the user is on the time entry page, when the user enters an invalid date, then an error
message should be displayed.
3. Given the user is on the time entry page, when the user selects a project, then the task
dropdown should be populated with the available tasks for the selected project.
4. Given the user is on the time entry page, when the user enters an end time that is less than
the start time, then an error message should be displayed.
5. Given the user is on the time entry page, when the user enters notes that exceed the character
limit, then an error message should be displayed.

Although not perfect, it provides a good starting point. However, there are some missing details in the story. It doesn’t specify where the task list or project list will be populated from or how they will be configured. Additionally, the story does not mention the mandatory fields that need to be included.

Moreover, the reason stated in the story, ‘so that I can focus on my work,” may not be a strong enough justification for an employee to enter a timesheet. It could be more effective if the reason were to be stated as ‘so that I can accurately track my time spent on the project’.

The generated UI mockup details were passed into the Figma Wireframe Designer to generate a UI wireframe. This plugin is a proof of concept that generates wireframe designs using the GPT model. It helps to generate wireframe mockups based on your prompt. The possibilities are endless with more components and better prompts as the model improves. The other tools worth exploring in this space are: visily.ai and Autodesigner by uizard.io.

Seen below is the user story view with story details, UI mockup, acceptance criteria and validation logic:

This is a good starting point for any business analyst to get started on a user story and fill in the blanks. The generated details can be further enhanced by elaborating on the problem statement and features in more depth. The quality of the response will depend on the clarity of the prompts and the specificity of the input or problem statement. As the language models continue to improve, incorporating more components and using better prompts can lead to even more accurate and comprehensive results.

Finally, we were able to set up the storyboard with all the stories.

The above exercise enabled the rapid exploration of different features with the knowledge provided by LLMs. The whole process can help in faster delivery and value creation for stakeholders while maintaining a structured and organised approach to requirements management.

We dedicated a few hours for trial and error to ensure the effectiveness of the five prompts. Each prompt takes approximately 2–3 minutes to generate a response. With the setup now complete, we can consolidate the prompts into a single tool that can be used across multiple problem statements.

Automating the Kickstart with Unprecedented Speed

Envision each organisation or business analyst defining a customised structure for epics and stories tailored to their specific needs and utilising a tool like this to automate the generation of functional and non-functional user stories with acceptance criteria. This ensures that requirements are well-defined and measurable. If the business analyst provides a customised structure and a well-defined problem statement with high-level solutions to such a tool, generating user stories can be just a click away. By leveraging this approach, business analysts can devote their energy to solving the problem at hand and collaborating with others to refine and iterate on the generated output.

This tool, with its prompts and customised structure, can be utilized by business analysts across various projects.

When custom language models increasingly become the standard, this approach streamlines the process of defining clear and measurable requirements, enabling organisations to achieve faster delivery and greater value creation for stakeholders, all while maintaining a structured and organised approach to requirements management, thus maximising the overall effectiveness of the software application.

What lies ahead?

The utilisation of Generative AI and the tools built upon it offers significant benefits in expediting the business analysis phase. They streamline the requirement gathering process, saving time and effort for business analysts and developers. However, it is important to note that while Generative AI tools are powerful, they may not analyse every aspect comprehensively, and thus, there is a possibility of gaps in the analysis.

It is crucial for business analysts and developers to exercise critical thinking and domain expertise to validate and refine the outputs generated by these tools. By combining the strengths of Generative AI with human expertise, we can achieve a more efficient and productive business analysis process, leveraging the AI tools to expedite the initial phases while ensuring thorough analysis through human oversight.