Genesys Cloud Web Messaging provides additional functionality for users who visit your website - you get the ability to chat with a bot or agent with a conversation history preserved.
GPT-3 is a language model developed by OpenAI that uses deep learning to produce human-like text. Taking the initial text as a cue, it will produce text that continues the given context.
Using the API, we can connect the GPT-3 model to the Genesys Cloud system using an integration that queries external web services - 'Web Services Data Actions'
The first thing we need to do is generate an API key in the OpenAI service.
The next step is to configure the 'Web Services Data Actions' integration. In the 'Contracts' section, we define an input variable named 'prompt' of type 'string' and 'text' also of type 'string' in the output.
In the 'Configurations' tab, we define the format of our request to the API.
We choose 'POST' as the HTTP transfer method and change the value of the 'Authorization' field to the key we generated earlier in the OpenAI service.
The body of the template has the variable '${input.prompt}' included, which is the input data received from the user, which we send as a request to the OpenAI service.
The last step of the configuration is to define the format in which the data will be returned. In the 'Response' section, we define a 'Translation map' function that parses the JSON data returned for our query by the OpenAI API.
We can check the correctness of the integration in the 'Test' tab.
If everything is working correctly we can go to the 'Architect' function and configure how the incoming messages should be processed - 'Inbound Message Flow'
We call the previously configured integration using the 'Call Data Action' function, specifying as input 'prompt' the variable 'Message.Message.body'. As the output of the function, we define a variable named 'State.text'. Before sending the response returned from the API to the user, we still need to get rid of a few escape characters such as a newline character or an apostrophe. Here we will use the 'Update Data' function which will modify our 'State.text' variable. We send the response from the API to the user using the 'Send Response' function
One example application is to create a Chatbot that answers questions from a 'provided context' so that it answers questions from previously provided information. Let's say you run an online store and you need an bot that will answer customer questions, but only if it knows the answer. For this you need a knowledge base - the most common answers without queries.
- our warehouse is located in Poland
- we do not send goods abroad
- we work from Monday to Friday
- we send packages via InPost company
- the only form of payment is transfer to a bank account
- we do not send parcels on delivery
We appropriately modify the query to the OpenAI API so that it can answer questions from the previously prepared knowledge base, and change the parameter 'temperature' to 0 to make the answers stick to the facts and be as little creative as possible.