Format input to send to an external API
# 🤝help
s
I want to ask the users a couple of questions and then contact an API. The issue is, I will ask them for city names, and the API needs it to be in a specific format, for example SYD for Sydney, NYC for New York, etc. How can I format the city names before sending it to the API? City names should match the names from this list https://www.iata.org/en/publications/store/airline-coding-directory/
a
hi @shy-glass-43299 👋 have you considered using an AI task to formulate the city names into the airport way you need them ✈️ ? I'd try something like setting up the AI task with the instructions of “Analyze the user’s message and set the string variable “cities” according to the airport code it corresponds to” and then feed that cleaned up variable to the API
s
Didn't work from the first attempt, but good idea, I can play with it a bit more. Thanks
a
Of course. Good luck and let us know once you figure it out!
2 Views