AI Chatbot Guide v1
AI Chatbot
Version 1

Function calls

Copy link

AI chatbot supported by engines such as OpenAI's ChatGPT has conversational features, but sometimes its flexibility delivers incoherent results. For better user experience, sometimes we need more deterministic and reliable responses. With the new function calling capability from OpenAI, AI chatbots can now respond by calling the functions set up in advance. On Sendbird Dashboard, you can set up these functions and incorporate it into your AI chatbot directly or use it as a part of a custom response.

How function calls work

Copy link

This section further explains how a function call works with the Sendbird server, OpenAI engine, and API calls.

  1. A user can enter a prompt in the chat interface, for example, ask "What's the weather in Seoul today?"
  2. The Sendbird server makes an API call to OpenAI, passing the user prompt and descriptions of certain functions.
  3. OpenAI then analyzes the semantic meaning of the user's question and matches with descriptions of the functions to determine which function should be used.
  4. For the user prompt example provided in step 1, the function get_city_weather is triggered because a user asked for the current weather of a city.
  5. OpenAI also extracts relevant parameters from the user prompt, such as city name, and passes it back to the server in JSON.
"role": "assistant",
"content": null,
"function_call": {
    "name": "get_city_weather",
    "argument": "{\"city\": \"Seoul\"}"
  1. Then, the server takes the function name and its parameters to make an API call.
  2. The output of this API call is in JSON format, so it's sent back to OpenAI GPT to craft a more natural, personalized response for the user.

How to create a function

Copy link
  1. On Sendbird Dashboard, go to Application > Chat > AI chatbot > Function calls > and click on Create function +.

  2. Enter the basic information for the function.



A name for the function. This name is only used for the dashboard.


A key to filter or identify the function by. Only letters, numbers, and underscores can be used.


A description for this function that allows the AI chatbot to determine when to trigger the function.

3. Enter the request information for the API call.


HTTP method

The action you want to perform.
-GET: Retrieve data
-POST: Create or send new data
-PUT: Update existing data
-DELETE: Remove data


The web address where the request is sent, telling the API exactly what resource you're trying to interact with.


Additional information sent along with the request, often used for authentication or specifying content type.

Request body

The actual data you're sending in JSON format. Required for a POST or PUT request.

4. Click on Send request and test your API call.

Incorporate it into your AI chatbot

Copy link

Using the function calls you created above, you can directly incorporate it into your AI chatbot.

  1. On Sendbird Dashboard, go to Application > Chat > AI chatbot > Manage bots and either click on an existing bot or create a new bot. For more information on how to create a new bot, see this page.

  2. In the bot detail page, you can select and add a function under Function calls as shown in the image below.

Incorporate it in your custom response

Copy link

Using the function call you created above, you can also use it in your custom response.

  1. On Sendbird Dashboard, go to Application > Chat > AI chatbot > Custom responses and click Create response +.

  2. In the Custom response section, select Function calls & Messages and choose a pre-made function from the Function calls dropdown list.

  1. For detailed guide on how to create custom responses, see this page.

To learn more, see Sendbird's AI chatbot product page.