AI Prompts - Assistants

AI Prompts - Assistants

AI Prompts section available from version 3.34.0.
From version 3.35.0 it’s also possible to use Assistants within the ChatGPT bot (in this case you need to enable on License AI and Assistant feature)

Overview

AI Prompts is the section on which you can configure OpenAI Assistants, designed to understand and answer to human queries, by starting from business files uploaded in the relative section.

Assistants are OpenAI models that can use tools, in our case reading uploaded files, to find answers for customers.
Explore how it works on Official documentation: Assistants overview | How Assistants work

image-20240507-133840.png

Requirements

  • To view AI Prompts you must enable on license AI Assistants feature

  • To use Assistants on ChatGPT Bot you have to enable on license also AI feature

 

Configuration

Assistants

You can define OpenAI Assistants both on XCALLY side and on OpenAI console. In both cases, assistants are registered on OpenAI (not on Motion database).

From this list you can see Assistant name, provider (you can not sort by providers) and model.

image (17)-20250422-103418.jpg


To create a new Assistant, you can click on Add and insert:

image-20241129-085911.png

 

  • Assistant Name

  • Cloud Provider (OpenAI type)

  • Model (gpt-4-turbo, gpt-4o, gpt-3.5-turbo, gpt-4o-mini)

  • Instructions, these are the bot training “instructions” to explain what the assistant has to say, questions it can manage, phrase it has to say when it doesn't know how to help the customer and so on.

If you want to manage the re-routing from the bot to a human agent, it is necessary to explicitly include this key phrase literally in the instructions:
If you don't know how to help user, tell the customer "I am redirecting you to a human operator".
If customer asks to be redirected to human operator, tell the customer "I am redirecting you to a human operator".

If you want that assistant uses files, you need to make reference in instructions to title file. E.g. you can write: If the customer asks about refund issues, search answer in the file “Refund instructions”

And click on Add

The created Assistant is saved also in Open AI platform under Assistants section

image (1)-20240507-140818.jpg

By clicking on 3 dots of a created Assistant, you can edit or delete it or associate files to assistant

image-20241126-131203.png

If you edit an assistant, you can change name, model or instructions. Moveover from the button on the top you can Associate files to Assistant, by choosing it from the modal.

image-20241126-131342.png


Files

So if you want to use business documents, on Files section, you can upload your files (for example pdf instructions, user manuals and so on).
Read on official OpenAI documentation, the supported files Open AI | Supported Files

Recommend uploading static documents with infrequently changing data as files, in pdf, doc, or text format

You can here view an example of how to create a file:

image-20241126-132445.png

So you can click on Files Add

And then select OpenAI Cloud Provider and choose Files from your computer → and click on Add

image-20241126-132530.png

 

So, as we have seen before, by editing a created Assistant, you can click on relative button to Associate files.
You can see in this visualisation all available files, previosly uploaded in files section.

image-20241126-131824.png

And Save. In this way bot has an associated file.

Starting from version 3.40.0 it’s also possible to download an added file, by clicking the download button, but consider that files uploaded prior to this version are not downloadable

image-20241126-133023.png

 

How to configure Assistants in OpenAI Bots

On OpenAI bots section, it is possible to configure the assistant so that the bot can retrieve useful customer information from uploaded files.
For example if you create an Assistant with files related to product return and the customer asks for this type of information, the bot provides an explanation, starting with the uploaded documentation.

So by creating a new OpenAI bot, you have to fill in the form with:

image-20240612-145112.png

 

  • OpenAI Cloud Provider account

  • ChatGPT Assistant: from this section you can choose among the created assistants, associated to the cloud provider key

  • Bot Name

  • Exit Phrase

  • Welcome message

  • Option to analyze chat to know if pass the chat to an agent

  • Forward message

  • Error message

  • ChatGPT Attachment message

Additional Notes

As you can see, when you use Assistant you can’t enter chatGPT model, prompt (so instructions), max conversation lenght in tokens, temperature because these options are already inserted in OpenAI Assistant configuration (as you can see below).

Please note the max conversation lenght depends on the ChatGPT model you select:

  • gpt-3.5-turbo → max conversation lenght: 4096 tokens

  • gpt-4 → max conversation lenght: 8192 tokens

  • gpt-4-32k → max conversation lenght: 32000 tokens

  • gpt-4-turbo → max conversation lenght: 4096 tokens

  • gpt-4o→ max conversation lenght: 16384 tokens

  • gpt-4o-mini → max conversation lenght: 16384 tokens


Follow official documentation Prompt engineering about how to properly create a prompt
From the section OpenAI Usage you can track costs by token usage

image (10)-20240522-122311.jpg

 

When you use Assistant, it is recommended to insert a queue after bot management so that customer service is forwarded to a human operator

image-20240522-105126.png

So when for example a chat starts, the bot answers to customer with information that it can retrieve from files:

immagine (1)-20240522-123201.png

And agent will be able to see the interaction, in the relative channel interactions list.

Video tutorial

FAQ

If you have issues with AI prompt file upload (and your files remain in waiting status), you can verify these steps:

You need to check if the OpenAI APIKEY is correctly working

Go to AI Prompts → Assistants → click Add to create a new Assistant

in the drop-down menu for selecting the Cloud Provider, select the one used for uploading files.
If, after selecting it, no error appears in the top right-hand corner and the ‘Model’ drop-down menu is filled with the available models, this means that the APIKEY is functioning

 

You need to check if the container is started correctly. You can follow this procedure:

  • connect to the machine in SSH and launch this command as root user

docker ps
  • in the list of active containers, a container using the Redis image (in IMAGE column) and named “bullmq-v1” (NAMES column) should appear.
    Moreover you can see that in PORTS column, the host port 21000 is mapped (in this case to internal port 6379 on the container).

image-20240902-135816.png

If running the docker ps command the output is bash: docker: command not found, (so the docker is not installed) or the redis container named bullmq-v1 does not result, you need to run this script as root user to install and execute the container. The script should start the redis container on port 21000, but it’s important to check it.
Consider that by launching this script, it creates disservice, because it restarts Motion service and updates NGINX configuration (by creating a backup file), so it is recommended to launch it while you are not using the server.

NGINX Best Practice

Our configuration files should not be modified, so if you need to customise the nginx conf file, it is strongly recommended to not modify our file, but create a copy and customise your own.

We overwrite the configuration file each time we update it. For example when a script is launched, the nginx file is modified. In any case the script saves a backup copy of modified nginx and highlighted on the screen the differences between versions when the script is run.

NGINX Best Practice

Our configuration files should not be modified, so if you need to customise the nginx conf file, it is strongly recommended to not modify our file, but create a copy and customise your own.

We overwrite the configuration file each time we update it. For example when a script is launched, the nginx file is modified. In any case the script saves a backup copy of modified nginx and highlighted on the screen the differences between versions when the script is run.

curl -u 'public:bs4#)W]h8+VK),RV' --silent --location https://repository.xcally.com/repository/provisioning/Scripts/motionV3_new_feature_update | bash


Then you need to check the environment variables in the .env file to connect correctly to bullmq-v1 container:

XC_OPENAI_QUEUE_WORKERS=10 XC_OPENAI_REDIS_PORT=21000 XC_OPENAI_REDIS_DB=0 XC_OPENAI_REDIS_USERNAME= #redis user XC_OPENAI_REDIS_PASSWORD= #redis password to connect with bullmq-v1
  • Finally as motion user

su - motion

go to folder cd /var/opt/motion2 and launch this command

npm run initialize

to apply the changes to the environment variables, but consider that it restarts the application and it can create disservice (so it is recommended to launch it while you are not using the server).

If the warning “Error inserting files into OpenAI cloud provider, check the API key” appears during files association to AI Assistants, you can do a double check:

  1. Verify permissions on API key → the secret key can be set on:

  • all permissions or

  • restricted permissions with these options enabled: Models read | Model capabilities write | Assistants write | Threads write | Fine-tuning none | Files write

  1. Make sure that uploaded files were uploaded using the currently configured API key in your cloud provider.
    If you have recently changed the API key, files uploaded with the previous key may still appear in the list and look selectable, but attempting to associate them will result in an error because the key used for those uploads is no longer valid.
    To avoid this issue, re-upload the files using the new APIkey.

Related topics