After getting slots from a user an API is called through which dynamic links get stored in a list and presented to the user from custom actions.py file… my problem is this → I want to show a clickable “View Here” for each dynamic link and inside that, I want to hide that link’s address…Is there any way that can be done??
Generic Process based on your front-end: utter_know:
- text: “To know more about rasa [View Here] (https://www.rasa.com/)”
OR
- text: “To know more about rasa [read more…] (https://www.rasa.com/)”
You can store the dynamic link value with :
Example:
class ActionWeatherapi(Action):
def name(self) -> Text: return "action_weather_api" def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]]: city=tracker.latest_message['text'] des=str(Weather(city)['weather'][0]['main']) description=str(Weather(city)['weather'][0]['description']) country=str(Weather(city)['sys']['country']) temp=int(Weather(city)['main']['temp']-273) hum =int(Weather(city)['main']['humidity']) dispatcher.utter_template("utter_temperature",tracker,temp=temp, city=city, hum=hum, des=des, description=description, country=country) return []
utter_temperature:
- text: “Today’s Weather in {city}, {country} is {description} with **{temp}**°C temperature and {hum}% of Humidity.”
This is just a small example to know how you can solve your problem. The values is depend upon based on your API and its JSON format. Same you can do with View Here link. Hope it will help you.
Your solution is helpful but now I’m trying to figure out how can I call utter_temperature as many times as the length of a list returned by my API , so that in one message it shows all the results returned by that API… am I clear for you to understand my problem?? Please help me with this
@bhuvan777 You want that your chat window will display all the response fetch by API? It can be 5 or 10 etc right?
How many response you want to return specifically? are those response varies every time user enter or they have fixed return values?
yes yes, there is no limit
Which API you using? Or is that you developed that? It should have some limit of response, else how you display everything on bot screen?
Me not clear with your last response yes yes, there is no limit.
It is a developed one. the range is from 1 to 15max.
@bhuvan777 any link?. I want to see the doc of that API, or JSON format, then I can share some solution. If you can share the API link or address?
“products”: [ { “reviews”: 0, “capacity”: 1, “productTitle”: " Photo Baba ", “productSubTitle”: null, “productName”: “Hemant Rathod”, “productAbout”: “Photography with exquisite results, stunning pre-wedding shoots.”, “productSpecifications”: null } ]
for eg this has returned single product detail , this no. vary according to user query
but the attribute value will be same? and output can be 2 or 15 right? as shown. Or is that attribute values also change?
let me explain, when a user searches for a product in a city then it shows a list which contains the booking details and some other info of that service provider so that user can click that and book the product…yes output vary product and city wise
I understand, yes same issue I faced when I want to show all the outputs, but when I wrote the output python code to show minimum display such as 5, I face the issue as output varies every time. It can be 2 or 3 and rest will show blank values (2 blanks or 3 blanks) which is not a right approach. Try to change the search criteria, so that It show fixed value or re-direct to some website or different approach. I hope you getting my point here? If you write the code for showing only 5 output, you will miss the rest output or if you get less output you will shown a blank or null output. Let other comments. Hope you will get the solution.