This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@classmethod | |
def name(cls) | |
return ‘google_assistant’ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def blueprint(self, on_new_message): | |
google_webhook = Blueprint('google_webhook', __name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@google_webhook.route("/", methods=['GET']) | |
async def health(request): | |
return response.json({"status": "ok"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@google_webhook.route("/webhook", methods=['POST']) | |
async def receive(request): | |
payload = request.json | |
intent = payload['inputs'][0]['intent'] | |
text = payload['inputs'][0]['rawInputs'][0]['query'] | |
if intent == 'actions.intent.MAIN': | |
message = "Hello! Welcome to the Rasa-powered Google Assistant skill. You can start by saying hi." | |
else: | |
out = CollectingOutputChannel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import json | |
from sanic import Blueprint, response | |
from sanic.request import Request | |
from typing import Text, Optional, List, Dict, Any | |
from rasa.core.channels.channel import UserMessage, OutputChannel | |
from rasa.core.channels.channel import InputChannel | |
from rasa.core.channels.channel import CollectingOutputChannel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rasa_core.agent import Agent | |
from rasa_core.interpreter import RasaNLUInterpreter | |
from custom import GoogleConnector | |
from rasa_core.utils import EndpointConfig | |
action_endpoint = EndpointConfig(url="http://localhost:5055/webhook") | |
nlu_interpreter = RasaNLUInterpreter('./models/current/nlu_model') | |
agent = Agent.load('./models/current/dialogue', interpreter = nlu_interpreter, action_endpoint=action_endpoint) | |
input_channel = GoogleConnector() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"actions": [ | |
{ | |
"description": "Default Welcome Intent", | |
"name": "MAIN", | |
"fulfillment": { | |
"conversationName": "welcome" | |
}, | |
"intent": { | |
"name": "actions.intent.MAIN", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RestaurantForm(FormAction): | |
"""Example of a custom form action""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RestaurantForm(FormAction): | |
"""Example of a custom form action""" | |
def name(self): | |
"""Unique identifier of the form""" | |
return "restaurant_form" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RestaurantForm(FormAction): | |
"""Example of a custom form action""" | |
def name(self): | |
"""Unique identifier of the form""" | |
return "restaurant_form" | |
@staticmethod | |
def required_slots(tracker: Tracker) -> List[Text]: |