Navigating your Chatbot
How do Functions work?
You can query real-time data and execute tasks directly from within the chatbot using Functions.
This is how a function looks like.
It has 4 things you need to setup.
- A descriptive function name
- A parameters object in the given format.
- A description explaining what this function does.
- Function handler – The code that needs to run when this function gets called.
For example:
I have created an example function in the above screenshot for getting current weather.
- I put the name of the function as
get_current_weather
- To get the current weather, I need to know the
location
and also theunit
in which I need to tell the temperature in. So I added them as parameters. - Then I wrote a
description
saying that this function gets current weather of a given location. - Finally, I wrote the actual code to get the weather. This code gets the request as the argument, and it needs to return a response. See the screenshot to understand what I am talking about.
So, now when the user asks What is the current weather in Paris
, SiteGPT will call the function get_current_weather
using Paris
as the location
.