OpenAI | ChatGPT

Video Series Coming Soon 🚀

Interact using AI. From replying to users to generating images, you can use OpenAI for a variety of tasks.

Integrating OpenAI's ChatGPT with Flochat can provides numerous benefits to businesses looking to engage with their customers across various channels.

With all the channels Flochat support, such as Messenger, Instagram, WhatsApp, Google Business Messenger, Voice, SMS, Viber, Line, VK, web chat, WeChat, and more, connecting with ChatGPT, You can offer businesses AI-powered conversational capabilities that can understand and respond to customer queries in a human-like manner, improving the customer experience and increasing engagement.

ChatGPT's advanced natural language understanding and generation capabilities enable our chatbot to understand the context of the conversation and offer personalised responses that are relevant to customer queries.

Combined with our multichannel capabilities, businesses can engage with their customers across their preferred communication channels, enhancing their overall experience. The result is improved customer satisfaction, increased engagement, and streamlined customer support, all of which can help businesses grow and succeed.

Flochat offers native integration with OpenAI, which enables users to set up the complex flow with just a click of a button.

Let us first see how we can establish a connection between OpenAI and Flochat.

Bridging Connection with OpenAI Account

1. Visit https://platform.openai.com

2. Login using your credentials.

3. Click on top-right corner on the “Personal” tab.

4. From here, you will be able to generate an api key.

You will only be able to see your api key once, so you can save the copy to a safe place.

5. Paste your API key inside Flochat and click “Save” to establish the connection.

Your account has successfully been connected with Flochat.

OpenAI Native Actions

Flochat gives a lot of actions with OpenAI which users can use for their needs.

We will now discuss them in detail one by one.

Create Text Completion

Text completion offers the functionality of sending prompts to OpenAI in textual form and based on the prompt receiving an answer.

Input:

Prompt: This is your main input for which you want the AI to give you an answer or output of. This can be a question, an instruction, etc.

Model: The model you want to use inside OpenAI for the task. By default, text-DaVinci-003 has been selected.

Max Tokens: Each task inside OpenAI consumes tokens. These tokens can be replenished using credit. This field puts a limit on the maximum number of tokens you want to use for a particular task.

Temperature: This acts as an accuracy gauge where higher values give more random answers and lower values give more deterministic and focused answers. It defaults to 1

Presence Penalty: This value makes OpenAI use unique phrases and texts when completing a task. The higher the value, less repetitive the words. It defaults to 0.

Number of Completions: The number of times you want the AI to generate a response based on your prompt. The higher value will result in more responses. It defaults to 1 in order to avoid the consumption of tokens.

Best of Completions: This returns the best possible response(s) for your prompt. It defaults to 1. This works with the Number of Completion field to choose the best possible answer from a group of responses.

Response:

Map the response to custom field

You can select the text under the choices, and then you can see the JSON Path selected, and then you can save the response into your own user custom field, and then use this response in your flow builder.

Sample Response Data

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 { "id": "cmpl-6zchlUy0OiAjX91LHOPBcZjuXaDgE", "object": "text_completion", "created": 1680144809, "model": "text-davinci-003", "choices": [ { "text": " 1. Understand Your Target Audience - Before you begin any marketing campaign, it’s important to have a clear understanding of who you’re targeting with your message. Researching and understanding your target audience will help you create campaigns specifically tailored to their interests. 2. Leverage Social Media - Social media has become one of the most effective ways to communicate with your target audience. Utilizing social media channels such as Facebook, Twitter, and Instagram can help you build", "index": 0, "logprobs": null, "finish_reason": "length" } ], "usage": { "prompt_tokens": 4, "completion_tokens": 100, "total_tokens": 104 } }

Id : The id of the text completion. A unique value.

Object : The action/task you gave to OpenAI. In our case “text_completion”

Created : A date-time field that tells the instance of the creation of the response. It is in Unix timestamp format.

Finish reason : The reason for the stoppage of the said task.

Prompt tokens : The number of tokens used to complete the task.

Best Practices:

Sometimes the completed response you get back seems to be cut off. This is due to the lack of the number of tokens required for the completion of the task. Simply adjusting the value of Max tokens inside the input fields will fix this issue.

It is also advised to adjust values like temperature, the number of completions, best of completions, etc to your use case by means of split testing. Every use case is unique and you should want the best possible utilisation of the resources available.

Image Generation

Image Generation is used to generate images based on the user-input prompts. This feature will generate the best possible image that matches your given prompt.

Input:

Prompt : This is your main input for which you want the AI to generate an image for you. This can be a question, an instruction etc.

Number of Images : The number of images you want the AI to generate for you. It is default to 1

Size : The dimensions you want the image to be. OpenAI support three sizes which are:

512x512

256x256

1024x1024

Response:

Sample Response Data

1 2 3 4 5 6 7 8 { "created": 1680145479, "data": [ { "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-2FEbJIRL7GXfKmGw2BT9wh9b/user-nk6UUN7L9nFqddzGEw67uTMonD/img-FhZpxMrCbiDBR4O62e7pPF08.png?st=2023-03-30T02%3A04%3A39Z&se=2023-03-30T04%3A04%3A39Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-29T17%3A40%3A49Z&ske=2023-03-30T17%3A40%3A49Z&sks=b&skv=2021-08-06&sig=4DF0dw/peG7FSVMUml4ShuQP98T0xECW1gE%2BeutdRAw%3D" } ] }

Created : A date-time field which tells the instance of creation of the response. It is in Unix timestamp format.

Url : The public URL for your image(s).

Best Practices:

Generating Images consume more computational power and hence the replies can be a delayed based on the prompts you give.

AI is a developing field and hence the images produced can be quite inaccurate given the complexity of the prompts provided. Hence finding the correct prompt complexity can sometimes be a challenge.

Speech to Text

Speech-to-text action is used when you want to convert audio input into text. This has variety of use cases such as implementation in IVRs.

Input:

File Url : This is the URL for the audio that you want to convert to text. Make sure that the url is a public hosted url ending with audio formats such as mp3. mpeg etc

Please note the url need to start with https:// and end with mp3, or mp4, mpeg, mpga, m4a,wav, webm

Language : The language you want the speech to be converted into. We use ISO-639-1 format which means you need to put languages as ‘en’, ‘es’ etc.

Response:

Sample Response Data

1 2 3 { "text": "Welcome to Rensen. This is a test to see if everything works well. And if the IVR can guide you to your work." }

Text : The text which is converted from the speech.

Best Practices:

You can convert speech to text quite accurately using this feature. It is considered a best practice to provide the audio in the same language as that of the desired output for more accurate results and latency.

Translate Audio to English

Translate audio to English action is used when you want to convert audio input into text in english language. This has a variety of use cases such as implementation in IVRs.

Input:

File Url : This is the URL for the audio that you want to convert to text. Make sure that the url is a public hosted url ending with audio formats such as mp3. mpeg etc

Please note the url need to start with https:// and end with mp3, or mp4, mpeg, mpga, m4a,wav, webm

Response:

Sample Response Data

1 2 3 { "text": "Welcome to Rensen. This is a test to see if everything works well. And if the IVR can guide you to your work." }

Text: The text which is converted from the speech.

Best Practices:

Experimenting with different formats of audio can provide more (or less) accurate results. This is simply due to the quality of the audio provided so make sure you split test with different formats to achieve the best possible format for your use case.

Create Chat Completion - ChatGPT

Chat completion offers a functionality of sending prompts to OpenAI in textual form and based on the prompt receive an answer. This is similar to text completion action but it uses ChatGPT which is 10x faster and cheaper as well.

Input:

System Message : This is an optional field and is used to provide additional context about you or your business when completing chats.

You can set up a detailed background information like this if you are building restaurant chatbot:

System: You are a steak restaurant helpful assistant. You will handle customer support, and guide the user and book reservations. The restaurant opening hours is 9am to 8pm Monday to Saturday, No pets allowed. Always offer the coupon code if you see it’s good timing to do so.

This will allow you to easily set up background information about the chatbot, and it can serve your client based on the information you instructed.

Message : This is your main input for which you want the AI to give you an answer or output of. Usually this is the user’s response. This can be a question, an instruction etc. You can add “user:” as a prefix to your prompt in order to provide more context to the AI for eg:

“user : will it rain today?”

It will also work if you don’t add “user” in front of the response. You can use our system field like {{last_text_input}}

Remember History: If selected “Yes”, the chat history between user and assistant will be saved in a system field to be used for later if needed.

The openAI action response will be automatically saved into assistant role. You don’t need to do anything.

Also, we have introduced a new system JSON field: {{openAI}} which will have all the chat history with the user:

You can find the openAI system field from your user profile. This JSON will save the system set up, and all the chat history.

Please note, our JSON field size limits is 20,000, if the chat history have more than 20,000 characters, we will delete from the oldest chat history in order to maintain the chat history within the limits.

Model : The model you want to use inside ChatGPT for the task. By default gpt-3.5-turbo has been selected.

Max Tokens : Each task inside ChatGPT consumes tokens. These token can be replenished using the credit. This field puts a limit on the maximum number of tokens you want to use for a particular task.

Temperature : This acts as a accuracy gauge where higher values give more random answers and lower values give more deterministic and focused answers. It is default to 1

Presence Penalty : This value makes ChatGPT use unique phrases and texts when completing a task. The higher the value, less repetitive words. It is default to 0.

Number of Completions : The number of times you want the AI to generate a response based on your prompt. The higher value will results in more responses. It is default to 1 in order to avoid consumption of tokens.

Best of Completions : This returns the best possible response(s) for your prompt. It is default to 1. This works with Number of Completion field to choose the best possible answer from a group of responses.

Response:

Sample Response Data

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 { "id": "chatcmpl-6zef5zEUdDzTx8VKu2r4gkIJfVcBE", "object": "chat.completion", "created": 1680152331, "model": "gpt-3.5-turbo-0301", "usage": { "prompt_tokens": 18, "completion_tokens": 100, "total_tokens": 118 }, "choices": [ { "message": {...}, // 2 keys "finish_reason": "length", "index": 0 } ], "messages": [ { "role": "user", "content": "can you help me with planting a mango tree?" }, { "role": "assistant", "content": "Of course! Here are some steps to plant a mango tree: 1. Choose a spot: Mango trees need plenty of sunlight and well-draining soil. They also need protection from strong winds, so choose a spot that's sheltered. 2. Prepare the soil: Mango trees prefer slightly acidic soil, with a pH between 5.5 and 7. If your soil is too alkaline, add sulfur or peat moss to lower the pH. If it's too acidic, add lime" } ] }

Id : The id of the text completion. A unique value.

Object : The action/task you gave to OpenAI. In our case “text_completion”

Created : A date-time field which tells the instance of creation of the response. It is in Unix timestamp format.

Choice -> Content : The content field inside the choice object contains the answer to your prompt.

Message: This is a JSON for complete conversation that has happened between the user and the assistant.

Best Practices:

Chat completion action enables you to provide JSON input as well hence you can save the complete conversation between the users and the assistant in a JSON to give more focused and contextual replies related to that conversation.

Since chat completion takes more input, the token consumption can be higher that text completion.

User cases: ChatGPT

How to fine tune ChatGPT for your business

If you use openAI embedding along with ChatGPT, you can train the chatGPT to answer your business related questions with complete ease!

Check the video below to learn how to implement this in your own business.

Generate the chatbot flow using A.I

Have you ever imagined that with a simple instruction like “create a flow to order pizza” and then Flochat can generate the whole flow automatically for you.

Everything is done with ChatGPT & Flochat.

Check the video below to explore this feature to get you started easily with Flochat.

Power up your live chat with the AI assistant

Have you ever think that you can use smart A.I assistant to using openAI embedding to generate the suggestion replies automatically?

This will increase your customer support efficiency and lower your customer support cost.

OpenAI Training Reply to Facebook and Instagram post comments

Have you ever thought to use openAI to reply to your Facebook, Instagram post comments automatically, and most importantly the reply will be highly relevant and accurate to your own business.

The reason is that we are using openAI embedding to get the highly relevant answers from your own business database, and this can be done automatically, learn how to set up from the video below:

Clear Remembered Chat History

Clear remembered history is used to delete or clear the system field where the chat history for chatGPT is stored.

This action will help you to reset the chat history.

The system field has a max character limit of 20000 characters after which it deletes the oldest key-pair value from the JSON in order to make room for newer values

OpenAI Embeddings & Building your Knowledge Base

OpenAI gives you the ability to provide a knowledge base of your use case or business for the AI to generate responses from. This enables the AI to give more accurate, contextual as well as particular answers instead of filtering them from the internet.

Create An Embedding:

To create an embedding, go into the Integrations and select OpenAI

Click on “New Embedding”

Type : This is an optional field. This is used to classify embeddings based on a certain context. Is used as a filter when there are a large number of embeddings associated. Always better to provide this field as it gives more context and becomes easier for AI to filter through.

Heading: The topic of the embedding that you have created. The title or summary.

Text : This is the text or main body of the embedding. The max character limit is 1000. You can put the details of the topic here for the AI to generate the response from.

Importing Embeddings:

Instead of manually creating embeddings you can create them in bulk by importing them as a CSV file.

Click on the drop-down arrow beside “New Embedding” and click on “Import CSV”

Now import the CSV file containing the embeddings and your embeddings will be created. If you have special characters like : è à ì ù, please select to “Import from csv without preview”

Make sure that the first rows of all columns should be the input fields name such as type, heading, text etc. and none of them should start with a capital letter.

Embedding Match & Completion Actions

The embedding match action is used to match the entered prompt with best-matching embedding from the knowledge base

Input:

Input : This is where you will input or map the prompt you want to match the embedding to.

Response:

Embedding : The heading of the embedding the prompt is best matched to.

Text : The text of the embedding the prompt is best matched to.

Input : The prompt that you input for embedding search.

Score : This is the % of the match between prompt and the embeddings available. You can use this score determine whether the following prompt should be used for completion or is not sufficient and will give inaccurate answers.

It is observed that a score of 0.79 and above gives the best possible embedding match. However this is an empirical value and you used split test for your use case in order to obtain best possible answers.

The embedding match and completion action is used to match the entered prompt with best matching embedding from the knowledge base and then generate the response using that particular knowledge base.

Input:

Input : This is where you will input or map the prompt you want to match the embedding to.

Introduction : This is used to provide more context to the prompt making the prompt more accurate and helps in raising the embedding match score.

Response:

Sample Response Data

1 2 3 4 5 6 7 8 9 10 { "status": "ok", "result": { "heading": "Free trial", "text": "Flochat offer 14 days free trial. No credit card required, you can access to all the pro features. You can sign up here: https://www.flochat.ai", "score": 0.903164959234692, "input": "Free trial for Flochat", "completion": " Yes, Flochat offers a 14-day free trial. No credit card is required and you can access all the pro features. You can sign up here: https://www.flochat.ai." } }

Embedding : The heading of the embedding the prompt is best matched to.

Text : The text of the embedding the prompt is best matched to.

Input : The prompt that you input for embedding search.

Score : This is the % of the match between prompt and the embeddings available. You can use this score determine whether the following prompt should be used for completion or is not sufficient and will give inaccurate answers. It is observed that a score of 0.79 and above gives the best possible embedding match. However this is an empirical value and you used split test for your use case in order to obtain best possible answers.

Completion : This is the output or the completion of the prompt the user input.

Using openAI embedding to reply your Facebook & Instagram comments

If you are running ads or have viral post on your Facebook page or Instagram. You may not have the time to attend those comments.

You don’t want to always reply some generic replies, and also you want to the reply is highly relevant to your business questions.

That’s why you need to use openAI embedding to provide highly relevant replies automated.

Check the video below to learn how to do it with Flochat:

Video tutorial for openAI integration & ChatGPT integration

We have prepared series to teach you how to build your first openAI powered chatbot. You can learn from our learning center.

Flochat learning centre:

OpenAI integration:

ChatGPT integration:

OpenAI Integration mini course

OpenAI Introduction

OpenAI Connecting OpenAI with Flochat

OpenAI text completion

OpenAI -AI image generations

OpenAI -Using embedding to build your business knowledgebase

OpenAI Training Reply to Facebook and Instagram post comments

ChatGPT integration mini course

OpenAI & ChatGPT integration with Flochat

ChatGPT is Live!!!

How to fine tune ChatGPT for your business

Create chatbot flows with ChatGPT!

Power up your live chat with the AI assistant

ChatGPT updates System message and saving chat history

Last updated