Add a Plug In to my Flow

(Michelle) #1

I want to be able to integrate the ability for folks to ask what the weather is at our resort. Can you inport plug in’s and if so where can I find a list of the available options?

(Khashayar) #2

You can do this with a weather API like this one:

https://openweathermap.org/current

The one here allows you to get the current weather for a geo cordinate.
The result is in JSON -> example here left hand-side is the messy code and right hand-side is the tidied up version

You can then set up FlowXo like this:

Bot Recieves A Message trigger: “what is the weather like” ->
Webhook: GET JSON (specify which part of the code you want with the data field) ->
Bot send message

Does that make sense?
If you set up the API, I can put an example flow together and give you some screenshots if you want.
But yeah, it’s simple with a weather API. You don’t need extra plug-ins!

(Michelle) #3

Thank you so much for your help. Unfortunately I am really new at this and so I have a couple of questions…

  1. What do you mean specify which part of the code you want with the data field?
  2. What do you mean by set up the API?

I’m sorry for all of the questions. I promise that I am a quick study. :slight_smile:
Thank you so much!!

(Khashayar) #4

Of course! Let’s go through it with more detail, again, using the free sample that the weather API gives us.

The trigger in this example is client asking for weather:

Then, we make a Webhook action and set it up like this:

We put the link as request URL, Method is GET (cause our information is always there - we just need to tell Flowxo to pick it up from that link) and the content type is set to None. I tried with JSON myself but it didn’t work. I guess the API wasn’t in JSON format after-all. I’ll explain this a bit later. It’ll look like this:

Now, Flowxo has all the code that is in that URL, which is this: http://www.jsoneditoronline.org/?id=f30ef3ef61da0e2a8fff4e2e9be92abb

We then make a Bot > Send Message action to tell our user what the weather is. But we don’t want to send them the whole code. We just want bits from that code. For example, we want to say:

The weather is [CURRENT WEATHER] and the humidity is around [HUMIDITY]

and have the brackets be pulled fresh every time we sent this message.

To fill these brackets, we need the data_field feature in Flowxo, which looks like this:

It appears when the output of an action can be many things. This is your way of telling Flowxo, which parts of the code you want to show.

Now, let’s go back to the right hand side of this. You see how there’s different information ‘nested’ inside each other? Using a service like JSONeditorOnline you can visually see these nests and find a way to get to them.

Every time you need to go down a nest, you put two underscores in front of the data_field. Like this:

Here, we’re telling Flowxo that when you look at the code you just got from the URL I gave you, you need to find a nest called ‘weather’, inside that nest, you need to find another nest called ‘0’, and inside of that, you need to get me the object called ‘main’. Again, we know this because we looked at the structure of the code before.

This would be our message:

and this is the outcome:

Or we can make the message more complex and use more of the data that our API gives us, combining it with natural language. Like this:

Which will give your user:

Now, how do you make one for your own latitude and longitude? You have to sign up for the API and set it to ‘look’ at your resort and give you a custom link so you can ‘GET’ this code from it.

There are many many weather APIs out there but the one we were testing has its pricing here: https://openweathermap.org/price

I think a free account is a good place to start for your use-case. The weather refreshes once every hour and you can GET from the URL up to 60 times in one hour.

When you sign-up, you’ll be given an API Key which is like a username and password so that the service can count how many times you’re using it. When you have that key, in your Webhook action, change the method to JSON and add your API Key as Authentication, in the field that appears. Everything else will be the same!

Hope this helped :slight_smile:

(Michelle) #5

Thank you so much! I was able to make it work because of all of your help!!! I really appreciate your patience.

All the best to you!

(John Jackson) #6

@kcfl Thank you so much for the detailed answer you gave above - will be a massive help for other users. :grinning:

1 Like
(Anish Duggal) #7

@kcfl, awesome share thanks!