-
Notifications
You must be signed in to change notification settings - Fork 85
/
actions.py
27 lines (17 loc) · 806 Bytes
/
actions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
import requests
class ApiAction(Action):
def name(self):
return "action_retrieve_image"
def run(self, dispatcher, tracker, domain):
group = tracker.get_slot('group')
r = requests.get('http://shibe.online/api/{}?count=1&urls=true&httpsUrls=true'.format(group))
response = r.content.decode()
response = response.replace('["',"")
response = response.replace('"]',"")
#display(Image(response[0], height=550, width=520))
dispatcher.utter_message("Here is something to cheer you up: {}".format(response))