GPT-3 in Your Pocket? Why Not!
Table of contents
GPT has become a very popular topic in recent times and is being used in many different ways, from automated customer service to natural language processing.
This tutorial will show you how to create a GPT-powered chatbot for the Viber app, using the WordPress and no-code plugin Convoworks WP. In it, we’ll explain how to set up the chatbot so that you can use GPT-3’s natural language technology to ask questions and converse about any topic.
Let’s get started!
Setup
To begin setting up your GPT powered chatbot for Viber, you will need to have a WordPress installation that is publicly accessible so it can receive requests from the Viber app. Then, navigate to the Plugin Installer and install and activate Convoworks WP. Once that is done, open Convoworks WP and create a new service using the "Import from file" option. The service definition (json file) can be downloaded here.
Create a Viber bot on https://partners.viber.com/account/. In order to do that, the only thing you need is an installed and working Viber app. Once you create it you will have an API access token which will be used in Convoworks. Note the QR code which you can use to invite users.
Now open your service in Convoworks, navigate to the Configuration view and click to enable the Viber platform. Here you have to enter Viber “Auth Token” and the “Account ID”. You can find account id number in your Viber account url at https://partners.viber.com/account/.
The last step is to set OpenAI auth key in the Convoworks service. In your service navigate to the Variables view and set the correct value. Here you can also set which model you are using and other parameters GPT API is using.
Now you just have to start using it. Go to your Viber app, open the More screen and tap on a QR code icon on top. Turn the camera to QR code on your Viber bot account page and you are in!
How does it works?
The conversation
GPT (Generative Pre-trained Transformer) is a type of algorithm that can understand natural language and generate new text based on a given prompt. It works by using the input prompt to construct a context, and then using that context to generate text.
The completion principle of GPT is that it will generate new text based on the context provided by the prompt. It is important to provide GPT with a prompt that provides enough context for the algorithm to generate related text. For example, if you provide a prompt like "What is the capital of France?", then GPT will generate text about France and its capital city.
So, what we are doing here in Convoworks service, is simply setting the ${conversation} variable (empty at the beginning) which contains the full conversation (check for “Set parameter” element). We are adding to it both the user's inquiry and the bot’s responses.
Http Query element
This component allows us to create API requests and use the response data. It will fetch a completion response, add it to conversation and prepare response text we can return to the user. This functionality is placed in a fragment so we can use it in several places in the workflow.
In this service we are using plain text filters to enable handling of the additional commands. Here is an example which catches “restart” or “start over” commands to reset conversation (sets ${conversation} variable to empty string).
Text filter and special commands
In this service we are using plain text filters to enable handling of the additional commands. Here is an example which catches “restart” or “start over” commands to reset conversation (sets ${conversation} variable to empty string).
Future ideas
Authentication
When Viber is sending requests, we are receiving the user's unique id too. If we have that id in our database, we could easily know user details and respond with a personalized message or conversation.
Prompt engineering
There is much power in knowing how to form prompts to get most of the GPT. Forming the right prompt is crucial and you should play with it. Keep in mind that Convoworks is running inside WordPress and can access all its data., meaning that you can pre-populate a prompt with data from the database. You can put different conversation context if it is a new user, what was their last order … whatever you need.
Conclusion
GPT-3 is an amazing technology, and it's incredible to see how it can be used to create powerful and useful applications. With the help of Convoworks, it's now possible to use GPT-3 within WordPress and Viber to create an intelligent, conversational bot. With a few simple steps, you can have GPT power in your pocket!
Subscribe to my newsletter
Read articles from Tihomir Dmitrović directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Tihomir Dmitrović
Tihomir Dmitrović
I’ve spent a significant part of my career in the mobile industry, such as during the 2000s when we had an explosion of new technologies and use cases. During that period I learned how to create tools which are able to easily follow technological changes, be ready for all possible use cases and yet to be easy to use and scale. Creating modular, component based, no-code systems which are able to solve very complex tasks became my speciality which led to creating my current startup, Convoworks.