To determine a number from a user phrase like “I have a temperature of 36 and 6 today”, you need to extract the value 36.6. The following steps describe how to do this.
Add a Question block and a Statement block.
Draw an arrow from the Question block to the Statement block.
Click on the arrow:
3.1. Action Type: Default.
3.2. Variable Name: question.
Insert the code into the BPL-expression field of the Statement block:
$context = "Your task is to determine what number is contained in the phrase I give you. Give me only the number to the nearest tenth, without rounding. Don't add any more words. Just the number itself and nothing else. Here is the phrase itself: "
$answer = gpt.ask("gpt-4o", $context :: $question, 0.5)
Where:
$context - the text that is added to the user's phrase.$question - a variable where the result of gluing the text from the $context variable and the user's phrase is stored.$answer - the response from ChatGPT.Use the {answer} variable in the script to get the number extracted by ChatGPT from the user's entered phrase.
In this way, you can extract numbers from user phrases and use them in your script.
To test the bot, use a web widget or messenger integration, since BPL operations are not performed when testing the script in the editor. For instructions on creating a test widget, see the article Test widget creation.