Closed floramarleen closed 1 year ago
Exalate commented:
floramarleen commented:
Are there any news about this issue?
➤ Maxime Verger commented:
:bulb: Heads up! We're moving issues to Jira: https://rasa-open-source.atlassian.net/browse/OSS.
From now on, this Jira board is the place where you can browse (without an account) and create issues (you'll need a free Jira account for that). This GitHub issue has already been migrated to Jira and will be closed on January 9th, 2023. Do not forget to subscribe to the corresponding Jira issue!
:arrow_right: More information in the forum: https://forum.rasa.com/t/migration-of-rasa-oss-issues-to-jira/56569.
Rasa version: 2.4.0
Rasa SDK version: 2.4.0
Python version: 3.8.5
Operating system: Windows
Issue: I connected my rasa open source bot to alexa by following the instruction given here: https://blog.rasa.com/connect-your-rasa-ai-assistant-to-amazon-alexa/. It works all fine except of the channel specific responses. It gives the output of the non channel specific responses and just ignores the ones I created.
Here is my alexa_connector.py:
import logging import json from sanic import Blueprint, response from sanic.request import Request from sanic.response import HTTPResponse #from typing import Text, Optional, List, Dict, Any from typing import Text, Dict, Any, Optional, Callable, Awaitable, NoReturn
import rasa.utils.endpoints from rasa.core.channels.channel import UserMessage, OutputChannel from rasa.core.channels.channel import InputChannel from rasa.core.channels.channel import CollectingOutputChannel
logger = logging.getLogger(name)
class AlexaConnector(InputChannel): """A custom http input channel for Alexa. You can find more information on custom connectors in the Rasa docs: https://rasa.com/docs/rasa/user-guide/connectors/custom-connectors/ """
@classmethod #def name(cls): def name(cls) -> Text: return "alexa_assistant"
alexa_webhook = Blueprint("alexa_webhook", name)
)
required route: defines @alexa_webhook.route("/webhook", methods=["POST"]) async def receive(request):
get the json request sent by Alexa payload = request.json
check to see if the user is trying to launch the skill intenttype = payload["request"]["type"]
if the user is starting the skill, let them know it worked & what to do next if intenttype == "LaunchRequest": message = "Hello! Welcome to the Privacy Bot. You can start by saying 'hi'." session = "false" else:
get the Alexa-detected intent intent = payload["request"]["intent"]["name"]
makes sure the user isn't trying to end the skill if intent == "AMAZON.StopIntent": session = "true" message = "Talk to you later" else:
get the user-provided text from the slot named "text" text = payload["request"]["intent"]["slots"]["text"]["value"]
initialize output channel out = CollectingOutputChannel()
send the user message to Rasa & wait for the
response to be sent back await on_new_message(UserMessage(text, out))
extract the text from Rasa's response responses = [m["text"] for m in out.messages] #message = responses[0] #give more than the first response message="" for res in responses: message=message+str(res)
" \n" #message = str(responses[0])
" "+str(responses[1]) session = "false"
Send the response generated by Rasa back to Alexa to
pass on to the user. For more information, refer to the
Alexa Skills Kit Request and Response JSON Reference:
https://developer.amazon.com/en-US/docs/alexa/custom-skills/request-and-response-json-reference.html r = { "version": "1.0", "sessionAttributes": {"status": "test"}
, "response": { "outputSpeech":
{ "type": "PlainText", "text": message, "playBehavior": "REPLACE_ENQUEUED", }
, "reprompt":
Unknown macro:
{ "outputSpeech"}
, "shouldEndSession": session, }, }
return response.json(r)
return alexa_webhook
Content of domain file (domain.yml) (if relevant):