Create a Chatbot Using Google MakerSuite and Angular

Google makersuite

Generative AI chatbots are the next generation of customer service and support tools. They can answer questions, provide recommendations, and even generate creative content. And now, with the help of Google MakerSuite and Angular, you can build your own generative AI chatbot, even if you’re not a machine learning expert. In this blog post, we’re going to create your very own Generative AI chatbot using two powerful tools: Google MakerSuite and Angular.

MakerSuite is a tool offered by Google for prototyping with generative language models. It gives you free access to Google’s powerful PaLM API, so you can experiment and put your Generative AI concepts to the test. Angular is a popular and powerful front-end framework for building web applications which is known for its speed, scalability, and ease of use.

To start building your chatbot, you’ll first need to create a MakerSuite account. Here’s the catch: access to MakerSuite is currently by invitation only, and if you haven’t already signed up for the waitlist, use this link to sign up.

Creating a Medical Diagnosis Chatbot

In today’s digital age, AI is rapidly transforming every industry, including healthcare. One of the most promising applications of AI is the development of medical diagnosis chatbots. These chatbots have the potential to revolutionize the way we receive healthcare, making it more accessible, affordable, and personalized. AI-powered medical diagnosis chatbots can analyze a patient’s symptoms and medical history to provide a diagnosis and treatment recommendations. So, we are going to use Google MakerSuite to create a medical diagnosis chatbot, that provides a diagnosis and treatment recommendation based on symptoms of the user.

First head on to Google MakerSuite and click “Create” button in “Chat prompt” card (Fig. 1) or click the “Create new” button on the left side menu (Fig. 2) and select “Chat Prompt” from the popup.

Figure 1 – MakerSuite Home
Figure 2 – Create New

You will be taken to the Chat prompt creation screen (Fig. 3). In the top left corner you can see “Untitled prompt”, here you can rename it. In this screen you can fine-tune PaLM API to generate answers as you want. This way, you can customize your chatbot to won needs. You can see some sample prompts that you can play around and see. Anyway, we are here to create a medical diagnosis chatbot, so in “Write your prompt examples” section, we can give instructions and examples on how chatbot should respond.

Figure 3 – Create Chat Prompts

Under context, you can provide the tone and the style the model should behave. For our project, we need our model to behave like a doctor. so you can provide the context like this:

“as a physician, provide medical diagnosis by asking symptoms from the users”

Then in the next section, you can provide few examples. In “User’s Input” provide the possible messages the user may send. Under “Model’s response” you can provide the type of response that you expect the model to provide. Here, either you can provide a response or use “Generate example” button to let the model generate a response. If you are happy with the respond provide by the model, you can keep it as it is, or you can tweak it as you need. Here I’m going to use the “Generate example” (Fig. 4) option. The example looks good so I’m going to keep it. I’ll be adding 2 more examples.

Figure 4 – Generate examples

Test your prompts

Now that we have provided enough examples to our model, let’s try it out in the “Test your prompt” (Fig. 5) section. You can ask the chatbot to diagnose your condition by providing symptoms. If the chatbot works well, you are good to proceed to the next step, if not, you will need to provide more examples or to tweak the given examples. Once done, you can save your prompt to your Google drive.

Figure 5 – Test your prompts

You can also play with model settings by clicking on the button with the model name on it (in this case “Chat Bison”, as we only have access to that model) (Fig. 6)

Fig 6 – Model settings

Create an API key

Now, we need to obtain an API key in order to connect our Chatbot app with the PaLM API. To get an API key, click “Get API key” icon (key like icon) from the left side menu. You will be redirected to the Get API key page (Fig. 7). Now click “Create API key in new project” (this will create a new project in Google Cloud console, if you want to create a key for an existing project on Google Cloud you can select “Create API key in existing project”)

Figure 7 – Get API key

Ok, now we have the API key, let’s connect the API with our Chatbot app. We are using Angular to build the frontend application for this chatbot. I have already created it for you. If you are familiar with Angular you can go through the code and understand it easily. If you are new to Angular I recommend you to follow the wonderful free course provided by the Angular team.

Connect API with Angular

To get the Angular project, just clone the project from GitHub. Navigate to the project and run NPM install to install relevant packages. Create a folder name “temp” under root directory and then create a file named “api-key.js” within the folder. Add the line below to the file:

module.exports = {
  my_api_key: '<YOUR_API_KEY>',
};

Replace ‘<YOUR_API_KEY>’ with the API key you created in the MakerSuite. Now open up a terminal and run:

npm run start:apiserver

This will run the API server. (We don’t add the API key to the Angular project as it is not a good practice. So we are running a NodeJS test backend). Now open another terminal and run:

npm run start:medibot

This will start the Angular app. Navigate to http:localhost:4200 in your browser. Now you can chat with Medibot, provide your symptoms and get medical diagnosis. (Fig. 8)

Figure 8 – Chat with Medibot

Conclusion

This is a very brief tutorial on how to use Google MakerSuite to rapidly prototype your Generative AI idea. As you can see, even if you are not a specialist in Machine Learning or AI, you are able to create a small Generative AI application on your own. In this tutorial we focused on Healthcare domain and build a medical diagnosis chatbot. So, I hope this blog post will help you learn about medical diagnosis chatbots, whether you are a healthcare professional who wants to improve patient care or a tech enthusiast who is interested in AI-driven healthcare solutions. Keep in touch to receive more such tutorials.