コード例 #1
0
ファイル: test_channels.py プロジェクト: whitewolfkings/rasa
def test_twilio_channel():
    with mock.patch.object(sanic.Sanic, "run", fake_sanic_run):
        # START DOC INCLUDE
        from rasa.core.channels.twilio import TwilioInput
        from rasa.core.agent import Agent
        from rasa.core.interpreter import RegexInterpreter

        # load your trained agent
        agent = Agent.load(MODEL_PATH, interpreter=RegexInterpreter())

        input_channel = TwilioInput(
            # you get this from your twilio account
            account_sid="YOUR_ACCOUNT_SID",
            # also from your twilio account
            auth_token="YOUR_AUTH_TOKEN",
            # a number associated with your twilio account
            twilio_number="YOUR_TWILIO_NUMBER",
        )

        s = agent.handle_channels([input_channel], 5004)
        # END DOC INCLUDE
        # the above marker marks the end of the code snipped included
        # in the docs
        routes_list = utils.list_routes(s)
        assert routes_list.get("twilio_webhook.health").startswith(
            "/webhooks/twilio")
        assert routes_list.get("twilio_webhook.message").startswith(
            "/webhooks/twilio/webhook")
コード例 #2
0
ファイル: test_channels.py プロジェクト: attgua/Geco
def test_twilio_channel():
    # START DOC INCLUDE
    from rasa.core.channels.twilio import TwilioInput

    input_channel = TwilioInput(
        # you get this from your twilio account
        account_sid="YOUR_ACCOUNT_SID",
        # also from your twilio account
        auth_token="YOUR_AUTH_TOKEN",
        # a number associated with your twilio account
        twilio_number="YOUR_TWILIO_NUMBER",
    )

    s = rasa.core.run.configure_app([input_channel], port=5004)
    # END DOC INCLUDE
    # the above marker marks the end of the code snipped included
    # in the docs
    routes_list = utils.list_routes(s)
    assert routes_list["twilio_webhook.health"].startswith("/webhooks/twilio")
    assert routes_list["twilio_webhook.message"].startswith("/webhooks/twilio/webhook")