Primechat
API DocumentsWebsiteLog in
  • START HEREđź‘‹
  • FAQ's
  • Pricing Plans
  • Getting Support
  • PLATFORM
  • Registration
  • Overview
  • Workspace & Members
  • CHATBOT GUIDE FOR BEGINNERS
  • Introduction
  • What is a chatbot
  • Benefits & importance
  • Use cases
  • FLOW BUILDER
  • Flow builder overview
  • Field variable
  • Steps
    • Steps
    • Question Step
    • Variable Operation
    • JSON Operation
    • External Request
    • Send Notification
    • Condition Step
    • Split Step
    • Go to Step
  • Sub Flow
    • Sub Flow
    • Workflow
    • Function Flow
  • CHATBOT CHANNELS
    • Omni+Channel Chabot
    • Webchat Chatbot
    • Facebook Chatbot
      • Facebook Lead Generation
    • Instagram Chatbot
    • Telegram Chatbot
    • Slack Chatbot
    • Wechat Chatbot
    • WhatsApp, SMS & Voice ChatBot
      • WhatsApp Cloud API
      • Set Up Facebook App
      • Get Your Webhook From PrimeChat
      • Start With Test Numbers
      • Build WhatsApp Chatbot With Test WhatsApp Number
      • Supported Message Types
      • Template Message
      • How To Use Template Message
      • WABA: Com Bot
    • Google Business Messenger
  • INTEGRATIONS
    • WooCommerce
    • Stripe
  • OPENAI & PRIMECHAT
    • Create chat completion
    • ChatGPT & PrimeChat Use Cases
    • How to fine-tune ChatGPT for your business
    • Generate the chatbot flow using A.I
    • Power up your live chat with the AI assistant
    • Reply to Facebook and Instagram post comments
    • OpenAI embeddings & building your knowledge base
Powered by GitBook
On this page

Was this helpful?

  1. OPENAI & PRIMECHAT

Create chat completion

PreviousOPENAI & PRIMECHATNextChatGPT & PrimeChat Use Cases

Last updated 1 year ago

Was this helpful?

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 detailed background information like this if you are building a restaurant chatbot:

System: You are a steak restaurant, helpful assistant. You will handle customer support, guide the user and book reservations. The restaurant's opening hours are 9am to 8pm Monday to Saturday. No pet is 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 the 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 that our JSON field size limit is 20,000 char, if the chat history has more than 20,000 characters, we will delete it from the oldest chat history 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 credit. This field limits 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

{ "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 that 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.