-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslack.py
21 lines (18 loc) · 950 Bytes
/
slack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from rasa_core.channels.slack import SlackInput
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
import os
from rasa_core.utils import EndpointConfig
# load your trained agent
interpreter = RasaNLUInterpreter("models/nlu/default/horoscopebot/")
MODEL_PATH = "models/dialogue"
action_endpoint = EndpointConfig(url="https://horoscopebot1212-actions.herokuapp.com/webhook")
agent = Agent.load(MODEL_PATH, interpreter=interpreter, action_endpoint=action_endpoint)
input_channel = SlackInput(
slack_token="xoxb-433387595414-431838839188-xi7JcipzMsXARwt1QkcRiAVj",
# this is the `bot_user_o_auth_access_token`
slack_channel="@slackbot"
# the name of your channel to which the bot posts (optional)
)
# set serve_forever=False if you want to keep the server running
s = agent.handle_channels([input_channel], int(os.environ.get('PORT', 5004)), serve_forever=True)