async def test_pushing_event_while_executing_side_effects( rasa_server: Sanic, params: Text ): input_channel = CallbackInput(EndpointConfig("https://example.com/callback")) channel.register([input_channel], rasa_server, "/webhooks/") rasa_app = rasa_server.asgi_client sender_id = str(uuid.uuid1()) conversation = f"/conversations/{sender_id}" serialized_event = test_events[1].as_dict() with aioresponses() as mocked: mocked.post( "https://example.com/callback", repeat=True, headers={"Content-Type": "application/json"}, ) await rasa_app.post( f"{conversation}/tracker/events{params}", json=serialized_event, headers={"Content-Type": rasa.server.JSON_CONTENT_TYPE}, ) r = latest_request(mocked, "post", "https://example.com/callback") if not params: assert r is None else: message_received = json_of_latest_request(r) assert message_received.get("recipient_id") == sender_id assert message_received.get("text") == serialized_event.get("text")
async def test_twilio_receive_no_previous_response(stack_agent: Agent): app = server.create_app(agent=stack_agent) inputs = { "initial_prompt": "hello", "reprompt_fallback_phrase": "i didn't get that", "speech_model": "default", "speech_timeout": "5", "assistant_voice": "woman", "enhanced": "false", } tv = TwilioVoiceInput(**inputs) channel.register([tv], app, "/webhooks/") client = app.asgi_client body = {"From": "Ray", "CallStatus": "answered"} _, response = await client.post( "/webhooks/twilio_voice/webhook", headers={"Content-type": "application/x-www-form-urlencoded"}, data=body, ) assert response.status == HTTPStatus.OK assert ( response.body == b'<?xml version="1.0" encoding="UTF-8"?><Response><Gather action="/webhooks/twilio_voice/webhook" actionOnEmptyResult="true" enhanced="false" input="speech" speechModel="default" speechTimeout="5"><Say voice="woman">i didn\'t get that</Say></Gather></Response>' )
async def rasa_server_without_api() -> Sanic: app = rasa.core.run._create_app_without_api() channel.register([RestInput()], app, "/webhooks/") return app
async def rasa_non_trained_server_secured(empty_agent: Agent) -> Sanic: app = server.create_app(agent=empty_agent, auth_token="rasa", jwt_secret="core") channel.register([RestInput()], app, "/webhooks/") return app
async def rasa_nlu_server(nlu_agent: Agent) -> Sanic: app = server.create_app(agent=nlu_agent) channel.register([RestInput()], app, "/webhooks/") return app
async def rasa_non_trained_server(empty_agent: Agent) -> Sanic: app = server.create_app(agent=empty_agent) channel.register([RestInput()], app, "/webhooks/") return app
async def rasa_server_secured(default_agent): app = server.create_app(agent=default_agent, auth_token="rasa", jwt_secret="core") channel.register([RestInput()], app, "/webhooks/") return app
async def rasa_core_server(core_agent): app = server.create_app(agent=core_agent) channel.register([RestInput()], app, "/webhooks/") return app
async def rasa_server_without_api(): app = _create_app_without_api() channel.register([RestInput()], app, "/webhooks/") return app
async def core_server(prepared_agent): app = server.create_app(prepared_agent) channel.register([RestInput()], app, "/webhooks/") return app