OpenAI

Abby Updated by Abby

Ready for chatGPT? click here to start (must add api key for it to work)

OpenAI is a powerful Natural Language Processing tool, that provides an API which can be easily integrated into your chatbot flow!

OpenAI is known for the creation of the GPT-3 model, a powerful deep learning model capable of producing human-like text.

In this tutorial we'll show you how to set it up in your bot and start using it right away

TLDR: Download the template here and start playing with GPT3 (must add api key for it to work)

Here's what the builder will look like:

Details
Before starting you'll need to set up an OpenAI account and create an API key

We'll start with a Text Question, here's how we set it up:

We added @response at the top, as that's where the output text from OpenAI will go once we loop back, if there's no response (like in the first iteration) it will simply not appear

The most important thing here is to save @text as the variable, as that's what we're sending to OpenAI

Next we'll add a webhook block with the following url: https://api.openai.com/v1/completions

Next we'll toggle on the Header, and add Authorization as the key, as the Token we'll add Bearer followed by the API key from OpenAI

Next we'll scroll down to Body and toggle it on, we'll then add the following:

{

"model": "gpt-3.5-turbo-instruct",

"prompt": "@text, summary @sumlist",

"temperature": 0,

"max_tokens": 200

}

The max tokens is up to you, these are the characters allowed, every group of words is a token

The temperature is how confident the bot is of the answer, the max temperature is 2, but it's not recommended as it could return gibberish

@text is the variable we saved from the input in the welcome message, this is what will be sent to the API, along with the @sumlist which is the summary of our previous questions, this will allow us to keep the context of the conversation and let us ask follow up questions

Let's test this and see if it works! We can add a test phrase and hit 'Test the request'

The response should look something like the above

In order to show only the text we'll need to save that part by clicking on the purple banner in save response

Once we've selected choices.0.text we'll save it as @response and then loop the webhook back to the welcome message after the formula

We'll connect the green output of the Webhook to a formula, which will create an array that saves each question asked

This is the formula we'll add: Push(@sumlist, @text) we'll save it as an array called @sumlist

Just in case something goes wrong, we'll need an escape route, so we'll connect the red output of the Webhook to the menu, allowing the user to try again, or go through a different flow

If you'd like, you can use our pre-made template

If you want to learn more about context in GPT3, we recommend this article

Looking to fine-tune your model? Check here

GPT Assistant

Check out our GPT assistant template here

Please note that for this template to work, you must add your OpenAI API key to the Set Variable block, in beginning of the bot

Generate Images with DALLE

Check out our DALLE template here

Please note that for this template to work, you must add your OpenAI API key to the Webhook, in the same format as previously mentioned in this article

OpenAI in WhatsApp

Click here for OpenAI in WhatsApp

How did we do?

Fine-Tune GPT3 with Postman

Prompt Engineering for GPT-3

Contact