# Custome action with weather api code

**URL:** <https://forum.rasa.com/t/custome-action-with-weather-api-code/21142>\
**Category:** Rasa Open Source\
**Created:** [November 12, 2019, 11:46am UTC](https://forum.rasa.com/t/custome-action-with-weather-api-code/21142 "2019-11-12T11:46:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunilskn](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@sunilskn](https://forum.rasa.com/u/sunilskn)\
**Post date:** [November 12, 2019, 11:46am UTC](https://forum.rasa.com/t/custome-action-with-weather-api-code/21142/1 "2019-11-12T11:46:51Z")

</div>

Hi i want to write custom action for weather api how can write api url: [http://api.weatherstack.com/](http://api.weatherstack.com/) api key : 062863cfebd4ad1479b484ce0dbfd228

intents like: what is the weather in london

---

<div class="post-metadata">

**Author:** ![JiteshGaikwad](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JiteshGaikwad](https://forum.rasa.com/u/JiteshGaikwad)\
**Post date:** [November 12, 2019, 12:57pm UTC](https://forum.rasa.com/t/custome-action-with-weather-api-code/21142/2 "2019-11-12T12:57:19Z")

</div>

hey @sunilskn, check this out:

> **[Weatherbot\_Tutorial/Full\_Code\_Latest at master · JustinaPetr/Weatherbot\_Tutorial](https://github.com/JustinaPetr/Weatherbot_Tutorial/tree/master/Full_Code_Latest)**
>
> master/Full\_Code\_Latest

---

<div class="post-metadata">

**Author:** ![vinoth](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/vinoth/32/5894_2.png) [@vinoth](https://forum.rasa.com/u/vinoth)\
**Post date:** [November 12, 2019, 1:33pm UTC](https://forum.rasa.com/t/custome-action-with-weather-api-code/21142/3 "2019-11-12T13:33:16Z")

</div>

hey @sunilskn, you can do like this , just replace the url and parse the data , must be working

from rasa\_sdk import Action

from rasa\_sdk.events import SlotSet

import requests

import json

class ActionCheckWeather(Action):

```
def name(self):
    return "action_check_api"

def run(self, dispatcher, tracker, domain):
    response = requests.get("https://jsonplaceholder.typicode.com/todos/1")
    jsonResponse = response.json()
    title = jsonResponse["title"]
    id = jsonResponse["id"]

    messageToUser = "The user id is {} and title is {} And this coming from an api call".format(id, title)
    dispatcher.utter_message(messageToUser)

    return []
```
