Just wanting to see if I'm understanding functions well

Hi guys,

I want to make this short and to the point.

I have a somewhat simple chat app wrapper that uses GPT4 API to receive messages from users and replies to them, it also has image generation and voice transcription functionality. However, I want to repurpose this and take a more enterprise approach and for that I want to know if functions (the way they are described in the API documentation) would work for my goals.

I want the company to feed the bot information regarding their business such as opening times, locations, products, etc. (This is not new I know)

But what I would like to do is try to make the bot automate beyond text replies and go a mile further such as sending the customer the location of their business OR setting up an appointment with one of the real vendors (if applicable ofcourse). This actions I want to understand if it’s possible to do them with the help of functions.

I’m sure you get the point, this is like customer service agents but with a brain. Idk if functions from openai can help me connect and call external APIs the way I’m describing.

Sample implementation

  1. Sending the customer the location of their business

tool call:

get_business_location({ name: ‘ACME’ })


{ name: ‘ACME’, address: ‘ACME Bldg, Tokyo, Japan, 123-456’, coordinate: [ 35.6895, 139.6917] }

When you receive the reply from the API and it has address and coordinate values, parse it then you can open a Google/Bing Map element and locate the business in the UI using those values.

  1. Setting up an appointment with one of the real vendors

tool call:

set_appointment_with_vendors({ name: ‘Taro Yamada’, vendor: ‘ACME, Inc.’, datetime: ‘2024-02-17T10:30:00+09:00’ })

Checks DB if datetime is available and if okay, adds appointment entry, then maybe send email to vendor and user.


{ status: ‘success’, message: ‘the appointment is added. check your email for more details.’, name: ‘Taro Yamada’, vendor: ‘ACME, Inc.’, datetime: ‘2024-02-17T10:30:00+09:00’ }

Hi supershaneski!

Thanks for your reply, based on your implementation I have some questions:

  1. Is it possible to make the bot use that function output to then call an external api in one single call?

For example:

The customer requests the location of the business, then chatgpt uses the location function and with the output it uses it on google map api and sends that to the customer on the chat :speech_balloon:.

You might consider what you can do in code and user interface, rather than in AI response language.

For example, if a business_location tool_call is the response you get from the AI, let’s say by using postal code or city name parameter, you can add UI widgets much like a search engine from the search your backend performs.

In assistants, you must return something to the AI and have the AI respond to the user if you want the thread to proceed.

On chat completions, though, you can use a function like a “trigger” and just await the next user input, only then including that the trigger was successful in chat history.

Apart from “functions, by their description only, should show how they can fulfill a variety of user requests”, the rules are yours to break.

1 Like

The external API call should happen in your code that fulfills the function call

The problem here regarding using UI components, is that Im a bit limited because Im using the Whatsapp APi to handle the chats from the users.

I’m not proposing any UI component.

You should have a server which handles all your API calls, including ones that go to third party services.

Sounds like you need to re-assess your architecture …

Sorry Robert I was replying to Jay F regarding UI components. And yes I know my architecture can be improved, Im new to the coding scene and still learning a lot. So far my whatsapp chatbot is coded in a Flask App that uses celery workers to handle incoming messages and uses Redis backend.

What do you think?

1 Like

whatever code is receiving the function call needs to make the third party API calls and return the results to the LLM