Build AI Agent with External API Data
Tutorial on how to build an AI Agent for your website with access to external data
Welcome to OpenAssistantGPT. In this guide, we will explain how to add an AI Agent with external API access to any website with just a few lines of code.
Create your GPT chatbot.
First, you need to create your chatbot if you don't already have one. Following this guide to create your first custom GPT chatbot
Create your Agent Action
This action allows your AI agent to access live API data to retrieve custom information.
In this example, we will create a custom weather assistant action. First, you need to open our Action Dashboard. Once you see the form, fill in the following information:
Name: get_weather_latitude_longitude
Description: Get weahter from longitude and latitude of the user.
URL: https://api.open-meteo.com/v1/forecast
Has parameters: true
Parameters:
- longitude: longitude number
- latitude: latitude number
- past_days: the past x days
- hourly: Hourly parameter the default value is temperature_2m
Once you have added all the parameters, press create. You can also test it yourself with the test option.
Assign action to your AI agent
Now that your first action is created, you need to assign it to your agent. To do this, open the Chatbot Dashboard and open the settings of the chatbot to which you want to add the action. Once you are in the settings, go to the "Action" option and choose the action you want to assign. After that, you can chat with your AI agent and ask, "What is the weather right now?" It will ask you for your location and then provide you with the current weather.
Now you can officially create an action for any API and you AI Agent can access live information.