ratty-blush•2y ago
Extracting a URL
I want to give users the option to access a pdf on a website. So I have a txt file in the knowledge base with some 70 URLs. Each URL has a unique code in it of the format 'AB123'.
I prompt the user to enter that code and then want to extract the appropriate URL so that I can send them to the document. I have tried to extract using AI response but it returns inconsistent values.
Can anyone suggest a suitable approach?
Thanks
6 Replies
To extract the appropriate URL from your text file based on a unique code entered by the user, you might consider leveraging the capabilities of Voiceflow's Knowledge Base. Here's a streamlined approach you could follow:
- Begin by uploading all URLs and their corresponding codes into the Knowledge Base. This can be achieved by adding a text file containing the URLs.
- Utilize the AI model to search for the unique code within the Knowledge Base. It may be necessary to tailor the AI model's prompt to specifically search for the code format 'AB123' and retrieve the associated URL.
- Given the potential for direct extraction via AI response to be inconsistent, it's advisable to employ a structured query or utilize custom code to sift through the text file for the code and subsequently extract the URL.
This method capitalizes on the Knowledge Base's functionality for storing and retrieving data, alongside the AI's ability to interpret and respond to queries. The success of this solution hinges on the AI model's training and the precision of the search instructions provided.
For comprehensive guidance on utilizing the Knowledge Base and AI models, consider these resources:
- Making Your Assistant Smart provides insights into adding data sources to your Knowledge Base, enabling your AI Assistant to generate responses based on the uploaded documents.
- Implementing the Knowledge Base offers a detailed look at creating a custom knowledge base with Voiceflow, including fetching content from various sources to answer questions effectively.
This revised approach ensures alignment with the provided 'chunks', offering a clear and accurate method for extracting URLs from a text file based on user-entered codes, leveraging Voiceflow's Knowledge Base and AI capabilities.
ratty-blushOP•2y ago
Text file of URLs already loaded. What custom code do you suggest?
I will not use a KB for that.
Instead you can add those URLs in an variable (array or an object) in your agent (or fetch a JSON file with an API Step if you want to be able to update the list) and do a search with a Javascript Step to retrieve the URL using the code.
So, if you're capturing user code in {userCode} variable and populating {theURL} with the matching URL,
in a Javascript Step, you can use something like this:
ratty-blushOP•2y ago
Hi NiKo
Thanks for this. I have got the JS script working and get the variable theURL OK.
I am not sure what to do next to get the URL activated and show the target document. What do I need to put in place of New Block 6 in the attached image?
Thanks
Steve

Use a button with an action set to OpenURL and pass your {theURL} variable here.
ratty-blushOP•2y ago
Thanks