Skip to main content
ChatGPT can be a great tool to help your support team answer most of the common questions that come up in your business and leave the important and complex questions to your human agents. It also helps you provide customer information about your product or service 24/7, even if your team isn’t currently online. In this guide, we will show you how to create a Support GPT flow that can be used to answer common questions and handoff to an agent if necessary.

Prerequisites

To complete this guide, you will need an OpenAPI key which will be used for authentication. If you don’t have an OpenAI account, you can sign up for one here. You also need to have created an assistant in OpenAI. You can follow the guide on how to do it here. We recommend using the playground if you’re not quite familiar with the API yet. Take note of your assistant_id as you will need it later. We will guide you in creating a simple flow that will answer questions from your customers with a handoff condition to send the conversation to a human agent if the question is too complex for the AI to answer.

Basic Flow Structure

A Support GPT flow will have a specific structure. Here’s an example of how to set it up: ChatGPT flow structure

Step-by-Step Guide to Creating a Support GPT

Step 1: Create a New Flow

  1. Navigate to Flows:
    • Go to Flows in your Hilos account.
    • Click on + Flow Editor to create a new flow.
  2. Name Your Flow:
    • Give your flow a name that reflects its purpose, such as “Support GPT Chatbot”.
  3. Select the Channel and Type:
    • Choose the appropriate channel (e.g., WhatsApp).
    • Select “Inbound” as the flow type.

Step 2: Set Up the Initial Trigger

  1. Configure the Trigger:
    • In the first step of the flow editor, set the flow type to incoming message. When publishing the flow set the trigger to Any Incoming Message, this ensures that the flow starts whenever a user sends a message to your support number.

Step 3: Add a Question Step

  1. Add a Question Step:
    • Click on the + button to add a new step.
    • Select “Question” from the list of step types.
  2. Configure the Question Step:
    • Ask the user for their query. For example: Hi there! How can I assist you today?

Step 4: Save the User’s Response

  1. Add an Update Contact Step:
    • Click on the + button after the question step.
    • Select “Update Contact” from the list of step types.
  2. Configure the Update Contact Step:
    • Save the user’s response inside a custom contact attribute called gpt_response (or any name you prefer).

Step 5: Integrate GPT for Answering Questions

  1. Add an API Step to Start the GPT Thread:
    • Click on the + button to add a new step.
    • Select “Connect API” from the list of step types.
    • Set the method to POST.
    • Enter the URL https://api.openai.com/v1/threads.
    • Set the content type to JSON.
    • Add an empty JSON object in the body. Add Api Step Example
  2. Configure the Headers:
    • Add the following headers:
      OpenAI-Beta: assistants=v1
      Content-Type: application/json
      Authorization: Bearer YOUR_API_KEY
      
      Headers Example
  3. Handle the API Response:
    • OpenAI will respond with a JSON object containing the thread_id. Save this ID for future API calls.

Step 6: Send the User’s Query to GPT

  1. Add an API Step to Send the Message:
    • Click on the + button to add a new step.
    • Select “Connect API” from the list of step types.
    • Set the method to POST.
    • Enter the URL https://api.openai.com/v1/threads/{{step.StartGPTThread.response.id}}/messages.
    • Set the content type to JSON.
    • Add the following JSON object in the body:
      {
        "role": "user",
        "content": "{{contact.gpt_response}}"
      }
      
      Add an API Step to send the Message

Step 7: Run the GPT Assistant

  1. Add an API Step to Run the Assistant:
    • Click on the + button to add a new step.
    • Select “Connect API” from the list of step types.
    • Set the method to POST.
    • Enter the URL https://api.openai.com/v1/threads/{{step.StartGPTThread.response.id}}/runs.
    • Set the content type to JSON.
    • Add the following JSON object in the body:
      {
        "assistant_id": "YOUR_ASSISTANT_ID"
      }
      
      Run the GPT Assistant

Step 8: Check for GPT Response

  1. Add an API Step to Check for Response:
    • Click on the + button to add a new step.
    • Select “Connect API” from the list of step types.
    • Set the method to GET.
    • Enter the URL https://api.openai.com/v1/threads/{{step.StartGPTThread.response.id}}/messages.
    • Set the content type to JSON. Check for GPT Response
  2. Add a Conditional Step:
    • Click on the + button to add a new step.
    • Select “Conditional” from the list of step types.
    • Set the condition to check if the GPT response is available.
  3. Configure the False Branch:
    • Add a delay step of 10 seconds.
    • Add a go-to step to loop back to the API step that checks for the GPT response.
  4. Configure the True Branch:
    • Check if the response from GPT indicates the need for human intervention.

Step 9: Handle Handoff to Human Agent

  1. Add a Conditional Step:
    • Click on the + button to add a new step.
    • Select “Conditional” from the list of step types.
    • Set the condition to check for specific keywords or phrases in the GPT response that indicate the need for human intervention.
  2. Configure the True Branch:
    • Add a message step to inform the user that their query is being handed off to an agent. For example:
      It looks like your question requires further assistance. I am transferring you to one of our support agents.
      
  3. Add an Assign Team Step:
    • Click on the + button after the message step.
    • Select “Assign Team” from the list of step types.
    • Choose the support team to which you want to assign the conversation.
  4. Configure the False Branch:
    • Add a message step to send the GPT response to the user if no human intervention is needed.
    • Add a new question step to ask another question and keep the conversation flowing.
    • Add an update contact step to save the new user response to the same custom contact attribute.
    • Use a go-to step to loop back to Step 6: Send the User’s Query to GPT.

Step 10: Save and Publish the Flow

Publish the Flow:
  • Click on the “Publish” button to make the flow active.

Example Flow Structure

Your flow should now have the following structure:
  1. Trigger: Any incoming message.
  2. Question Step: Ask the user for their query.
  3. Update Contact Step: Save the user’s response.
  4. API Step: Start the GPT thread.
  5. API Step: Send the user’s query to GPT.
  6. API Step: Run the GPT assistant.
  7. API Step: Check for GPT response.
  8. Conditional Step: Check if the GPT response is available.
    • False Branch:
      • Delay Step: Wait for 10 seconds.
      • Go To Step: Loop back to check for GPT response.
    • True Branch:
      • Conditional Step: Check if human intervention is needed.
        • True Branch:
          • Message Step: Inform the user about the handoff.
          • Assign Team Step: Assign the conversation to the support team.
        • False Branch:
          • Message Step: Send the GPT response to the user.
          • Question Step: Ask another question to keep the conversation flowing.
          • Update Contact Step: Save the new user response.
          • Go To Step: Loop back to Step 6: Send the User’s Query to GPT.

Final Steps

  1. Test the Flow and Optimize:
    • Send a test message to your support number to ensure the flow triggers correctly and the GPT responses are accurate. Also take into account the real conversation your users might have and adjust the GPT prompt and knowledge base accordingly to improve the responses.

Conclusion

Creating a Support GPT chatbot with Hilos is a powerful way to enhance your customer service capabilities. By setting up an inbound flow with question steps, API integration, and conditional logic, you can provide instant answers to common questions and efficiently route more complex queries to human agents. Start building your Support GPT chatbot today and take your customer service to the next level!