Skip to main content

ChatGPT using OpenAI APIs

Using ChatGPT within Glific using the OpenAI APIs

Leverage the capabilities of GPT models developed by OpenAI by using OpenAI APIs.

3 minutes readLevel: AdvancedLast Updated: December 2025

How it will work

  1. Question is asked by the user after the flow is initiated
  2. OpenAI API call is made using webhooks within the flow
  3. Question, prompt to the model, and the type of model being called to answer the question or perform the task is provided inside the webhook params
  4. The response is returned from the GPT models which can be sent to the user directly or used as desired in the flow.

Using the webhook for OpenAI API call in a Glific flow

Screenshot 2024-09-25 at 11 10 13 AM

Representative image to explain the steps in OpenAI API calls in a simple flow

Sample flow

  1. Get the user question
  2. Add a call a webhook node.
  • By default, FUNCTION would be selected. Leave this as it is.
Screenshot 2025-12-03 at 11 13 18 AM
  • In the FUNCTION field, select the pre-defined function parse_via_chat_gpt from the dropdown.
Screenshot 2025-12-03 at 11 14 05 AM
  • Give the webhook result name - you can use any name. In the screenshot example, it’s named gpt_response.
Screenshot 2025-12-03 at 11 14 44 AM
  1. Add the parameters in the FUNCTION Body.
  • Click on Function Body on the top right corner. You would see the following.
Screenshot 2025-12-03 at 11 16 57 AM
  • Pass the following parameters as mentioned below.

{ "question_text": "@results.question_1", "gpt_model":"gpt-4o", "prompt":"Answer in less than 5 sentences." }

here question_text is the parameter name corresponding to user question.

gpt_model is the parameter to help you select the best model for performing the given task. The model name must correspond to the text models given in the OpenAI API documentation. See OpenAI models documentation

Screenshot 2025-12-03 at 11 25 27 AM
  1. The response from GPT is shown as @results.webhookresultname.parsed_msg, in the given example gpt_response is the webhook result name. (see the first image)

Reach out to the Glific team to flag any further customizations within this functionality