How to Connect your AI Chatbot to the Internet

How to Connect your AI Chatbot to the Internet

Connecting our AI Chatbot to the internet only takes some few minutes using our platform. We've already covered this concept in a previous blog, but since we've significantly simplified and improved the process, we feel it's time to revisit it.

AI Agents and AI Functions

AI functions are at the heart of our AI agents technology. When you're creating an AI chatbot that's connected to the internet, you're actually using our AI agents technology. The process is extremely easy due to our no-code and low-code AI platform, and doesn't require any coding at all - So don't be scared by names such as "AI agents" and "AI functions". Everything is done without coding using nothing but natural language and prompt engineering.

Below is a video where I go through the entire process, and create a new AI chatbot from scrath, and connect it to the internet - All is done in 5 minutes. If you prefer a written explanation, you can find one below the video.

How to Connect your AI Chatbot to the Internet

We will need 3 AI functions to connect your chatbot to the internet. All of these functions can be found inside of our OpenAI plugin, and they are as follows.

  • Search the web
  • Search the web and return only URLs
  • Scrape URL

By combining the above AI functions with DuckDuckGo, your AI chatbot has everything it needs to perform web searches, summarize URLs, etc. The steps for connecting your AI chatbot is easy.

  1. Install the OpenAI plugin
  2. Create a new type or use an existing
  3. Change its system message using the "Flavor" dropdown to "AI Agent"
  4. Done!

Below is a screenshot of choosing the AI Agent system instruction. Remember to install or re-install the OpenAI plugin to gain access to this system instruction.

Making your AI type become an AI Agent

When you're done with the above your system message will contain a whole range of AI function declarations, allowing your chatbot to execute these functions when instructed accordingly. The internet related parts of your system message can be found below.

## Search the web and return only URLs

If the user asks you to search the web or research some topic and the user
only wants URLs to be returned, you will inform the user of what you're about
to do by informing the user about the search query you're about to use, for
then to end your response with the following function invocation.

___
FUNCTION_INVOCATION[/modules/openai/workflows/workflows/web-search-return-urls.hl]:
{
  "query": "[VALUE]",
  "max_urls": 10
}
___

Description of arguments:

- [query] is mandatory and will be used as a search query while searching DuckDuckGo
- [max_urls] is optionally and becomes the number of URLs to return, and unless
  explicitly changed by the user should default to 10

## Search the web

If the user asks you to search the web or research some topic and does not explicitly
tell you to return only URLs, you will inform the user of what you're about to do by
informing the user about the search query you're about to use, for then to end your
response with the following function invocation.

___
FUNCTION_INVOCATION[/modules/openai/workflows/workflows/web-search.hl]:
{
  "query": "[VALUE]",
  "max_tokens": 10000
}
___

Description of arguments:

- [query] is mandatory and will be used as a search query while searching DuckDuckGo
- [max_tokens] is optionally and becomes the number of tokens to return, and unless
  explicitly changed by the user should default to 10000

## Scrape URL

If the user asks you to scrape or fetch some URL, you will inform the user of what
you're about to do and end your response with the following function invocation.

___
FUNCTION_INVOCATION[/modules/openai/workflows/workflows/scrape-url.hl]:
{
  "url": "[VALUE]"
}
___

Description of arguments:

- [URL] is mandatory and the URL that will be scraped

Parts of the original system instruction have been removed in the above example, but I suggest you read through it all to understand what it does. The AI Agent system instructions contains a lot of interesting AI functions you can leverage, especially in password protected AI systems combined with our AI Expert System.

Notice, some of the default AI functions the AI Agent system message installs are not suitable for being consumed in a publicly available chatbot. There's one AI function for instance that allows the user to execute SQL which you'd probably want to remove - Especially for a publicly available chatbot. The AI agent flavor is by default intended to be used with the AI Expert System and only accessible for authenticated users whom you trust.

However, if you remove the insecure AI functions, you can embed the resulting AI chatbot on a publicly available website if you want to provide web search and internet connectivity to your website visitors.

How AI Functions Works

If you look carefully at the above partial system message, you will notice how it instructs OpenAI to return JSON given some specific condition. Magic Cloud will trigger a function invocation when it encounters JSON returned from OpenAI. This allows us to phrase prompts such as the following to execute functions.

  • "Search the web for Thomas Hansen Hyperlambda and create a summary"
  • "Scrape microsoft.com and return all outgoing hyperlinks"
  • Etc ...

Under the hood we're using DuckDuckGo in addition to our proprietary website scraper, but DuckDuckGo apparently is built on Bing search again, which ensures very high quality. Below is a screenshot of how the end result might end up looking like when consumed from our AI Expert System.

Searching the web using our AI Expert System

In the above screenshot I'm connecting our AI chatbot to the internet to perform a web search and return the first 5 URLs it finds. But the sky is really the limit here. Everything that's accessible on the internet can in theory be consumed by the AI chatbot.

Example Queries

Your imagination here is the only limiting factor, and you've probably got thousands of queries yourself you want to test it with - But below I've listed some few example queries you can try.

  • "Scrape TripAdvisor and return 5 high quality vegan restaurants in Oslo"
  • "Search the web and find out how the weather will be tomorrow in San Francisco"
  • "Scrape ProductHunt and return the top 5 products"
  • "Scrape microsoft.com and return the first 20 links you find"
  • "Search for housemaids in Larnaca and return the phone numbers to the first 3 you find"

The above are of course just simple examples, and I'm sure you've got plenty of ideas yourself for how to use this. One of my favourite examples is to use it in combination with sending emails to leads, and have the AI agent scrape my lead's website, for then to generate a personalised sales pitch it sends as an email. This requires an additional AI function, but can be entirely done using no-code and prompt engineering. Below is a screenshot if you're interested.

Sending emails from your AI Chatbot

The above is accomplished by by choosing your type under the machine learning component in its "Training Data" tab, for then to click "Add function", and find the "send-email" function.

There's a lot of other additional internet related AI functions, allowing you to connect your AI chatbot to anything that's on the internet - More or less - But I'll wrap up now before this article becomes too long to read for you.

Wrapping up

An AI chatbot that's connect to the internet can provide additional value by helping you "find the needle in the haystack". The combination of web search, internet connectivity, and AI, allows you to much more rapidly find the information you're looking for. In addition it allows you to process your search and scrape websites to generate summaries and find specific information from the scraped sites.

More importantly, by connecting your AI chatbot to the internet, it acquires "agent capabilities", allowing it to actually do things instead of just passively generate text output. Imagine an AI chatbot that's password protected and can send emails, book flights, integrate with SalesForce or HubSpot, etc. The sky is literally the limit here.

At AINIRO we specialise in delivering AI chatbots that are connected to the internet, or your existing applications, or your existing databases, etc. If you're interested in learning more about our technology a good place to start can be found below.

Thomas Hansen

Thomas Hansen I am the CEO and Founder of AINIRO.IO, Ltd. I am a software developer with more than 25 years of experience. I write about Machine Learning, AI, and how to help organizations adopt said technologies. You can follow me on LinkedIn if you want to read more of what I write.

Published 17. Aug 2024

AI Agents, the Future of Work and Software Development

How will AI Agents change the way we work? And how will they change how we deliver applications? In this article I answer that question at the best of my abilities.

Read More

What is an AI Agent?

AI Agents allows an LLM such as ChatGPT to 'do things' by connecting the LLM to an API or a database. Another word for it is AI Assistant.

Read More

Go Fuck Them Elon!

Elon Musk has delivered a lawsuit against the Global Alliance for Responsible Media, and at AINIRO we say it's about time somebody creates some trouble for this mafia industry.

Read More