So far, you have decided when to run the agent yourself. Now, you will connect the same agent to an external event. So, for example, when a new requirement is received, it can automatically trigger a new analysis. Let's dive in. the past two lessons, we built our basic agent loop that turns a requirement into a structured review of the facts, ambiguities, clarification questions, and assumptions. Then, we added a verification loop that evaluated the output based on completeness, clarity, and depth, and retried, making sure all these criteria passed. In this lesson, we are going to add the event-driven loop. In this loop, an external event, like a Slack message, will trigger the agent to review a requirements report, and return the result as a Slack message to the user. Event-driven loop makes our agents easier to use, by connecting them to the tools where the work is already happening, like Slack. GitHub, or Jira. This reduces friction. Say you want to review a requirement. If you have to open a separate agent, copy the requirement, paste it, and ask for a review, that's several extra steps. Even if the review is useful, you might not do it every time. But if the agent is available right where the conversation happens, conversation is happening, using it becomes a natural part of the workflow. Or the agent can be automatically triggered when a requirement changes, so it responds when it's needed. In this lesson, first, we will see the event-driven loop in action. In the next step, you will learn how to run the agent loop yourself on your local machine by cloning the repo and setting up the integrations on your end. Finally, we will look at how to build your own event-driven loop using the verification loop of lesson four as the start point and the specifications you can give to a coding agent, like Claude Code, to build the same event-driven loop built in this lesson. Let's now see how our requirement review agent can work in Slack, Jira, and Confluence. If Slack is part of your team workflow, it will be nice if you can directly chat with a Slack bot that runs the Requirements Review Agent you built in the past two lessons. Here, I have a Slack bot that runs our Requirements Review Agent. Let's say I'm working on the user profile upload feature we already discussed so far, and I would like to have a quick review of it in Slack. In reality, the requirement I will write might be more comprehensive compared to this, but here we just want to see how the agent is working from Slack. Let's now send this requirement for review. The Requirements Review Agent is now working on the requirement. And now, its response is ready. The agent returned the Requirements Analysis with Confirmed Facts, Ambiguities, Clarification Questions, and Assumptions, and finally a Summary in this Slack message. Besides this format of the message that is returned by the agent for easier and quicker review in Slack, the agent also returns this Raw Markdown format for easier copying and using in other parts of the workflow. You can also add the same requirement review Slackbot to a team channel. Here, I have a channel called product-eng-sync, where the team discusses new products and features. The engineering lead has posted about a problem that urgent alerts are getting buried under marketing pings and read receipts. And then another team member has also commented with prioritizing this feature. Now let's say I am the PM working on this feature. I have done some initial analysis and put together a list of requirements. Before turning this into a Jira ticket, I want to get some quick feedback, so I can simply call the agent right here in the channel and ask it to review my requirement. This way, the agent's feedback can become part of the team discussion. I can simply mention the Requirements Review Agent, and send this as a reply in the same message. Now the agent is working on the requirements review. Let's wait a minute. The agent returned this response with confirmed facts, ambiguities, clarification questions, and assumptions, and finally, a summary. Now, with the possibility of further team discussion, this can become a new Jira ticket to be implemented. Many software teams use tools like Jira and Confluence in their workflows. For example, they might use Jira to break down work into tasks, assign them to team members, and track progress. And they might use Confluence to document features, goals, and requirements. You can set up automations in Jira and Confluence to trigger the requirements review agent that you have built so far. Let's see what this looks like in Confluence. Here, for example, I have a requirement, "Add file upload to user profile" in Confluence. Now, let's say I want the agent to review this requirement. I have already integrated the agent with Confluence. So I can simply go here, click on Automate, select the Requirement Analysis Agent, and click on Automate. And here we have the response from the agent, which is added as a comment to the same Confluence page for review, with Confirmed Facts, Ambiguities, clarification questions, assumptions, and summary. You can do a similar integration directly in Jira, such that if a Confluence page is linked in a Jira ticket, the agent can pull it from Confluence and return the response directly in Jira. You can run the same event-driven loop on your machine. You need Python 3.12 or higher, an OpenAI API key for the requirement agent, for Slack integration, a Slack workspace where you can install an app, And for Jira and Confluence integration, an Atlassian Cloud site where you can create API tokens and automation rules. And to run the agent on your local machine, you can follow these steps: clone the repo, then go to the repo, then in repo directory, create and activate a virtual environment, install all the requirements, and make sure the environment file has all the keys that are needed. To create and integrate with Slack, make sure that in the environment file you have the OpenAI API key given. and then create the Slack app by going through these six steps. While doing this, you will get App-Level Token and Bot Token that you will add to the environment file. Then run this file, and you should be able to use the requirement review bot in Slack. For Jira and Confluence integration, in the first step, get the Atlassian API credentials by going here and getting and adding these keys to the .env file. Then run this file. For Jira and Confluence to connect to your local agent, you will need a tunneling service to expose it publicly. In this project, I used a free service from ngrok, but you can use other similar services, too. Then, follow these steps to add automation to Jira, and these steps to add it to Confluence, and all should be ready for you to try it yourself. If you run into any issue at any step of integrating your agent with Slack, Jira or Confluence, I recommend using an AI coding agent to find and solve the problem. If you would like to build the event-driven loop yourself, from scratch instead of using the final repo that we saw, you can use the spec.md file that is given in the resources and materials section of this lesson. You can provide this spec to your coding agent with Lesson 4 verification loop helper functions as the start point, and create the event loops from scratch yourself. You can also modify this spec file to create event loop for integrating your agent with other tools and platforms you use in your workflow. The spec file has a section for the main goal, for building integrations with Slack, Jira, and Confluence, and the starting point that is basically the helpers we had in Lesson 4 verification loop. Then in this section, the final result is going to be these two files: slack_bot.py and jira_webhook.py. There's also this section that has shared design rules For example, this rule here that in both Jira and Confluence, the response should be new comments and not editing the original ticket or the requirement page. The next section are the specs that are specific to Slack bot, and similarly, a specific section for Jira and Confluence webhook, and also a section for the acceptance checks to verify that what is built is working fine. And finally, a list of requirements that we explicitly ask to not be built. I recommend building the Slack and Jira integrations from scratch using this spec file yourself by giving it to a coding agent, or modifying it to build event triggers for your agent in another tool in your workflow. In this lesson, you learned how events can make your agent become more usable and also saw how the same agent we built in the last lesson can be integrated with Slack, Jira, and Confluence. In the next lesson, we will focus on the hill climbing loop, where an analyst agent is going to analyze the traces of our agent and identify common patterns of failure and propose changes to the harness to make the agent run better in the future runs. All right, see you there.