Build Question Answering Chatbot for Church Sermons with Amazon Transcribe, LangChain, OpenAI, FAISS, and AWS AppRunner
This post was inspired by the AWS Blog: Build a powerful question answering bot with Amazon SageMaker, Amazon OpenSearch Service, Streamlit, and LangChain.

In today’s era of rapid technological advancements, Generative Artificial Intelligence (GenAI) is transforming how we interact with knowledge from various domains, including Faith and Christianity. In this blog post, we will show to how to build a question answering chatbot for church sermons, leveraging the capabilities of Amazon Transcribe, LangChain, OpenAI, FAISS, and AWS AppRunner. By combining these powerful tools and services, we can enable personalized spiritual guidance, rooted in the knowledge of Christ, for everyone, including the next generation. Let’s dive into the fascinating world of question answering sermon chatbots!
Step 1: Capturing Church Sermons with Amazon Transcribe and BeautifulSoup
To begin, we utilize Amazon Transcribe, a state-of-the-art automatic speech recognition (ASR) service, to convert the audio church sermons from Pastor Poju Oyemade into text. We used the BeautifulSoup Python library, to scrape the sermons from the Covenant Nation e-library website.

Once we have the audio files downloaded, we upload them to an Amazon S3 bucket, which triggers an Amazon Step Function State machine. This process initiates the transcription job with Amazon Transcribe, and the resulting transcripts are saved to another S3 bucket for further processing.


Step 2: Building the Vector Database with FAISS and OpenAI
For efficient retrieval and analysis of sermon content, we employ FAISS (Facebook AI Similarity Search), a powerful library for similarity search and clustering of dense vectors. To construct the vector database, we use the OpenAI Embeddings model API to convert the text into meaningful embeddings. These embeddings, using the LangChain framework, are then stored in the FAISS index with LangChain Vector stores API, enabling fast and accurate retrieval of relevant sermon segments based on user queries.

Step 3: Retrieval Augmented Generation using LangChain and OpenAI
To provide intelligent responses to user queries, we leverage LangChain, an innovative approach that combines retrieval-based and generation-based techniques. By utilizing the FAISS vector database, LangChain performs a similarity search to retrieve the most relevant sermon segments. We then employ OpenAI’s powerful language models like GPT-3.5 to generate contextually rich and personalized responses based on the retrieved text. This fusion of retrieval augmented generation ensures that the chatbot delivers accurate and engaging answers to user inquiries.
Step 4: Hosting the Chatbot on AWS AppRunner with Gradio
To make our question answering bot easily accessible, we use Gradio, a simple yet powerful Python library for creating customizable UIs for deploying AI models. With Gradio, we developed a simple chat interface where anyone can interact with the chatbot by inputting their queries and receiving informative responses.

For easy deployment, our question answering bot application is hosted as a containerized application on AWS AppRunner, a fully managed service that automates the deployment and management of containerized applications. This ensures a seamless and hassle-free user experience.
Feel free to chat with the bot: https://bit.ly/PastorPojuAIAssistantBot
Conclusion
In this blog post, we showed how to build a question answering chatbot for church sermons using the advanced capabilities of Amazon Transcribe, LangChain, OpenAI, FAISS, and AWS AppRunner. By combining the power of automatic speech recognition, advanced language models, similarity search, and containerized application hosting, we can create an immersive and interactive experience for anyone seeking spiritual guidance in Christ. This question answering bot enables easy access to sermon content, and personalized responses. Embracing AI and ML technologies in the realm of Christianity and Faith enhances the accessibility and relevance of personalized spiritual growth in the digital age.