AI Insights

From Data to Empathy: Building and Deploying Chatbot for Real-World Impact in Disaster Zones

March 19, 2024


article featured image

In February 2023, Turkey and Syria, were rocked by devastating earthquakes, registering magnitudes of 7.0 and 6.5 respectively on the Richter scale. These seismic events unleashed widespread destruction, causing thousands of casualties and displacing countless individuals from their homes. The affected regions faced a myriad of challenges, from collapsed infrastructure hindering rescue efforts to overwhelmed emergency services struggling to provide aid.

Amidst the chaos, the imperative for innovative disaster management strategies became starkly evident. Technology emerged as a beacon of hope, offering novel solutions to address the pressing needs of those affected. One such solution is the implementation of an AI-powered chatbot—a virtual assistant capable of delivering real-time assistance and crucial information to disaster-affected individuals.The chatbot serves as a lifeline, providing immediate access to vital resources such as FAQs, safety guidelines, and directions to nearby relief centers. Its primary aim is to bridge the gap in communication that often arises during disasters, ensuring that accurate information reaches those in need when traditional channels fail.

In our upcoming article, we will introduce two specialized virtual assistants tailored to meet distinct needs in disaster response. The first one is designed for Public Safety Answering Point (PSAP) operators and 9-1-1 dispatchers, while the second caters to individuals seeking emotional support and guidance, particularly from a psychological perspective, amidst crisis situations.

This article comes from the Omdena Innovation Challenge. More info is available here.

Role of Personality in General

The research conducted by Kern and their team, titled “Social media-predicted personality traits and values can help match people to their ideal jobs,” investigates the congruence between individuals’ personalities and their occupations. The study provides evidence that occupations have distinctive psychological profiles, which can be predicted from linguistic information collected through social media. Utilizing data from 128,279 Twitter users across 3,513 occupations, the researchers assessed user personalities and mapped the personality profiles of different professions. This approach allowed them to visually identify clusters of similar occupations, highlighting specific jobs that individuals might be well-suited for. Additionally, the research revealed potential emerging occupations relevant to the 21st-century workplace, illustrating how social media can be employed to match people with their ideal occupations.

The study’s results indicated that user occupations could be predicted with a high degree of accuracy based on their psychological profiles derived from text data. For instance, the machine-learning models used in the study achieved prediction accuracies higher than 70% across various classifiers. This finding suggests the viability of using linguistic information from social media to identify well-fitting jobs based on individuals’ personality traits and values. The research underscores the potential of creating an atlas of career aptitude based on noncognitive personality traits and values, offering significant implications for career guidance across various demographics, including new graduates, disengaged employees, career changers, and the unemployed.

This research shows how we can use personality traits and values found in text to make chatbot interactions better fit the psychological profiles related to different jobs. When designing chatbots for disaster assistance, it’s beneficial to consider two primary chatbot assistants: those emulating Public Safety Answering Point (PSAP) operators and 9-1-1 dispatchers, and those offering emotional support and guidance akin to a psychologist’s role during crises. 

For chatbot assistants modeled after PSAP operators and 9-1-1 dispatchers, the design should focus on emulating a communication style that is clear, concise, and directive. This design choice aligns with the operational demands of emergency response, where quick decision-making and efficient information exchange are paramount. Such chatbots would effectively serve users in need of immediate, action-oriented assistance, mirroring the professional conduct of their human counterparts in emergency situations. Conversely, chatbot assistants designed to provide emotional support and guidance should adopt an approach similar to that of psychologists. These chatbots would emphasize empathetic, supportive, and open-ended interactions, offering solace and understanding to individuals seeking psychological comfort in times of distress.

Kern’s research underscores the importance of aligning chatbot assistants’ communication styles with the psychological profiles typical of the occupations they represent. This alignment ensures that AI interactions are not only personalized and engaging but also capable of meeting the specific needs of users during emergencies. By tailoring chatbot design to reflect these different roles, developers can enhance the effectiveness and reliability of chatbots in disaster assistance, ensuring they provide the appropriate level of support, whether for logistical coordination or emotional reassurance.

Let’s Meet Our Virtual Assistant DIMA

We’re focusing our efforts on California—a state well-known for its seismic activity. By leveraging recent polls and data analysis, we’ve made our services broadly accessible by emphasizing English language capabilities. This ensures that users nationwide can benefit from our chatbot, which is designed to offer essential support during times of crisis. The integrated chatbot within our application serves as a vital resource during crises, offering real-time assistance and support to individuals in distress. Beyond providing essential information such as locating relief shelters and sharing safety updates, it also seamlessly integrates with our application’s mapping feature to guide users to the nearest shelters with driving instructions. Additionally, our alert system ensures timely notifications tailored to users’ preferences, whether through email, SMS, or in-app alerts based on their location or chosen zip code, facilitated by continuous monitoring through a cron job. These features are key to our mission of ensuring preparedness and offering quick responses in disaster situations.

To refine our chatbot’s capabilities, we categorized potential user questions into seven key areas, each with a brief explanation and an example:

  • Knowledge. Offers information about earthquakes, “What causes earthquakes?
  • First Aid. Provides procedures and guidance for emergency medical situations, “How do I treat a broken arm until help arrives?
  • Safety and preparation. Share tips for staying safe before, during, and after earthquakes, “How should I prepare my home for an earthquake?
  • Information and contacts. Details on the locations of hospitals, shelters, and Red Cross centers, “Where is the nearest relief shelter located?
  • Alerts. Gives timely updates on earthquake activity, “Is there an earthquake warning for today?
  • Location. Offers functionality to give users instructions on how to reach safety,  “How do I get to the nearest hospital from my current location?
  • Emotional Support. Offers advice for managing stress and fear related to earthquakes, “How can I manage anxiety after an earthquake?” This feature aims to support mental health by providing tips for emotional coping and resilience.

These categories helped refine the chatbot’s scope by pinpointing specific functionalities and information it should offer within the project’s timeframe. Moreover, they directed our development efforts towards serving targeted user groups more effectively. The potential questions also played a key role in identifying the data needed to train and develop the chatbot.

Leveraging DataCamp’s Resources in Crafting our Workflow Architecture

In the thick of disaster management, the effectiveness of our chatbot is a direct reflection of the real-time, diverse data it digests. It operates on the pulse of live updates, ensuring the information relayed is both immediate and precise. The chatbot is currently configured to handle an array of data types, from safety protocols and emergency contacts to GIS mapping and local resource information. These data types are paramount for providing actionable intelligence to those in crisis. As part of the Data Gathering phase, we accumulate a comprehensive inventory of critical data. This data is then funneled through our Trigger Pipeline, which performs real-time validation checks using advanced functions in pandas and SQL to confirm the integrity of incoming information. This includes, for instance, ensuring tabular data features essential columns like facility names and location coordinates.

Our Ingestion Pipeline is the backbone of our data processing, standardizing column names, purging duplicates, and appending new columns for mapping directions and geographic coordinates. This pipeline is essential for maintaining the database’s accuracy and freshness, which in turn keeps our chatbot’s responses relevant and timely. Text data undergoes a similar rigorous ingestion process. Documents are categorized and preprocessed using natural language processing techniques, tapping into the capabilities of modules like checks_text.py for content categorization and preprocessing_text.py for refining the data. Our GitHub Actions workflows are pivotal here, automating the ingestion of data to streamline efficiency and promote collaboration within our team.

Architecture

Architecture

Furthermore, the integration of advanced methodologies and tools further enhances our chatbot’s capabilities. Unstructured data is processed through chunking and embedding using OpenAI’s text-embedding-ada-002, enhancing data representation and context. Our solution employs a retrieval-based RAG methodology to synthesize responses through a Language Model (LLM), ensuring the information provided is as precise and helpful as possible. The LangChain framework orchestrates the seamless integration of components, constructing agents equipped to address queries efficiently. Pinecone, a cloud-based vector database, and Supabase for storing tabular and user information, underpin our system’s ability to quickly retrieve relevant data. Custom tools like the vector_retrieval_tool and SQL_retrieval_tool augment the chatbot’s ability to provide accurate and timely responses.

The workflow of our chatbot reflects a sophisticated system where a user query initiates a process of determining the appropriate action, combining retrieved information with the original query to synthesize a final, informed response. This robust system ensures that our chatbot, whether delivering structured emergency instructions with the efficiency of a 9-1-1 dispatcher or offering empathetic support like a psychologist, draws from a well-informed and timely data source to interact effectively with users. Enhancements such as hierarchical agent teams, task-specific models, ranking algorithms, and a query refinement system are considered for future improvements. These would not only streamline operations but also enhance the quality and efficiency of our chatbot’s responses, ensuring it remains a vital tool for disaster management.

We are grateful for the support of DataCamp through their DataCamp Donates program, which provided us with invaluable resources and training to develop and refine our chatbot, including access to DataCamp Professional for a year. This partnership enabled us to harness the power of data science and AI in creating a solution that significantly contributes to disaster management efforts.

Through DataCamp, we were able to access a wide range of courses that directly benefited our project. These included AWS courses covering various aspects crucial to our infrastructure, prompt engineering for refining our chatbot’s interactions, DVC for efficient version control, geospatial analysis for location-based functionalities, CI/CD for seamless deployment pipelines, LangChain for optimized language processing, and Pinecone for advanced data retrieval. Additionally, the DataCamp Workspace proved instrumental in our development process, allowing us to run Python scripts, connect to the project’s database, and execute SQL code to model new tables and enhance data management capabilities.

The knowledge and skills gained from these DataCamp resources were pivotal in overcoming challenges and implementing innovative solutions within our chatbot, ultimately ensuring its effectiveness in real-world disaster response scenarios.

Differences in Prompt Engineering between Dispatcher Personality and Psychologist Personality

At the heart of these digital assistants is prompt engineering, a pivotal element that shapes the chatbot’s interactions, ensuring that communication is both personalized and effective. By tailoring chatbot prompts with information derived from official training guides and adhering to national standards, we empower our chatbots to provide not just precise emergency guidance but also empathetic support to users in need.

These prompts are meticulously tailored to suit the designated personalities of PSAP operators or 9-1-1 dispatchers and psychologists, drawing from official training materials, national standards, articles, and published papers on emergency first aid for natural disasters. This customization process is integrated within the retrieval-augmented generation tool, ensuring the chatbots’ responses are both informed and empathetic.

For the psychologist persona, the prompts are structured based on the field operation guide for training first-aid disaster psychologists, published by the National Center for PTSD and National Child Traumatic Stress Network. This approach emphasizes equipping individuals with the skills to overcome obstacles themselves, promoting sustainable long-term recovery from disasters.

Prompt for psychologist persona

Prompt for psychologist persona

Conversely, prompts for the PSAP operator or 9-1-1 dispatcher persona are crafted using standardized workflows and best practices in the US, sourced from the national 9-1-1 website. These standards cover a wide range of responsibilities, from stress management and information gathering to handling complex emergency events like suicide prevention and human trafficking.

Prompt for PSAP operator or 9-1-1 dispatcher persona

By reviewing the differences between the system prompts for each persona, users can gain insight into the tailored approaches taken to address the specific needs of PSAP operators or 9-1-1 dispatchers and psychologists in disaster scenarios.

You can review the differences of the system prompts and response testings between the two personalities, respectively, as follows: 

Chatbot with the 9-1-1 dispatcher personality

Chatbot with the 9-1-1 dispatcher personality

Chatbot with the Psychological Personality

Chatbot with the Psychological Personality

Role of Data in Database for Learning

The effectiveness of our chatbot in emergency situations greatly depends on it having a broad and high-quality set of data. To ensure that we can offer the best support to users, possibly in critical and stressful conditions, our data collection is both extensive and trustworthy. We’ve gathered a rich array of resources, including documents, charts, and comprehensive information on disaster-related subjects, all sourced from reputable experts such as FEMA and the Red Cross.

To guarantee the accuracy and practicality of this data, we’ve systematically organized and polished it according to its type. We deal with two principal kinds of data: tables, which are stored in .csv format, and text, found in .txt and .pdf formats. Each type is specially processed to make sure our chatbot operates smoothly and efficiently.

Initially, the tabular data includes essential details like the geographic coordinates of various places, their addresses, contact numbers, and descriptions of critical facilities such as hospitals, shelters, and Red Cross centers. This information is crucial, especially for use during and after earthquakes.

Before making this data available to users, we first check  the names of the columns to ensure consistency, remove any duplicate entries to maintain data integrity, and then proceed with validation checks. After passing these steps, the data was securely stored in a Postgres database on Supabase, ready for use when needed.

For handling the text-based data, we took a different tactic. We set up a special process using the OpenAI API that helps sort, summarize, and organize the more than 120 documents we collected. Initially, we sorted these documents by their format, either PDF or text files. After that, the OpenAI API helped us pull text from these documents and put them into four groups: those about earthquakes, other disaster topics, general information, and unrelated content. This system made it possible for us to manage all these files automatically, saving a lot of time and effort. After sorting, the documents were placed into our Pinecone vector database for storage.

Once the data was in our database, we needed to check its quality. To do this, we created a special program, also using the OpenAI API, which would ask specific questions to see if our project’s information was accurate and relevant. It would look for answers in our Pinecone database, bring back the results, and then evaluate them. This step made sure our information was reliable and useful for our needs.

After processing the data, it reaches our users through what we call the Query Pipeline, which simplifies connecting the app’s interface to our databases. Let’s say there’s been an earthquake, and you urgently need to find the nearest hospital because someone you care about is hurt. You would tell our chatbot, named “DIMA, ‘Take me to the nearest hospital.’” This question involves finding a location, so DIMA checks our tabular database (hosted on Postgres) for this. The chatbot figures out where you are based on your ZIP code and then shows you the two closest hospitals. If your question needs information from our text-based data (stored in Pinecone), DIMA looks for the five most relevant pieces of information and gives you a summary of them.

Why don’t we just use the GPT Chat model for our chatbot instead of building our own databases?

Sure, GPT can answer general questions about disaster response, like what to do during an earthquake or what emergency supplies are needed. But it has limitations, such as creating responses based on incorrect information or not being able to offer up-to-the-minute details. This is where our chatbot stands out—it’s built to give our users critical, real-time information about shelters and medical services when they need it most. This feature is especially important during emergencies like earthquakes, helping to keep users calm and collected.

Conclusion

The devastating earthquakes in Turkey and Syria in February 2023 underscored the urgent need for innovation in disaster response, showcasing chatbots as indispensable tools in these critical moments. These events highlighted the essential role of technology in providing immediate assistance, guiding those affected to safety, and offering comfort amid chaos. In this context, chatbots emerged not just as communication tools but as vital components of emergency response efforts, demonstrating the profound impact of technological advances in enhancing our resilience and readiness for future challenges.

As we look to the future, the potential for personalized chatbots in disaster assistance is boundless. By continually refining their functionalities, we aspire to enhance their effectiveness, making them more attuned and responsive to users’ needs. Our ongoing dedication to leveraging technology for humanitarian purposes reaffirms our commitment to keeping chatbots as indispensable tools in disaster management.

Recognizing the importance of emotional intelligence in times of distress, we plan to implement sentiment analysis to make the chatbot more attuned to users’ emotional states. This will enable it to not only provide information but also offer comfort and understanding, crucial for maintaining a supportive dialogue between the chatbot and its users.

Moreover, introducing a robust feedback mechanism will be crucial for the chatbot’s continuous improvement, allowing for adjustments based on user interactions and preferences. Combined with enhancements in user experience and interface usability, these improvements promise to significantly amplify the chatbot’s utility. By forging stronger partnerships with emergency response agencies and leveraging the latest technological advances, we aim to cement the chatbot’s role as a vital disaster management tool, ever-responsive to the changing needs of the communities it serves.

This article is written by Sabina Sujecka, Elianneth Cabrera, Yiling Ding, Flo Caro.

Want to work with us?

If you want to discuss a project or workshop, schedule a demo call with us by visiting: https://form.jotform.com/230053261341340

Related Articles

media card
Building an AI Chatbot for Interview Preparation using NLP
media card
AI-Powered Chatbots Initiative to Enhance Mental Health Support
media card
Revolutionizing Reforestation: The Impact of Chatbots in Forest Restoration Efforts
media card
AI-Powered Safe Route Prediction for Earthquakes