Skip to content

Commit

Permalink
add pyngrok to telephony app (livekit#149)
Browse files Browse the repository at this point in the history
* add pyngrok to telephony app

* port taken from --port arg

---------

Co-authored-by: Rey <[email protected]>
Co-authored-by: jusgu <[email protected]>
  • Loading branch information
3 people authored May 25, 2023
1 parent 5315642 commit f26d4df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion apps/telephony_app/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
from fastapi import FastAPI

from pyngrok import ngrok
from vocode.streaming.telephony.config_manager.redis_config_manager import (
RedisConfigManager,
)
Expand All @@ -10,6 +10,7 @@
from vocode.streaming.telephony.server.base import InboundCallConfig, TelephonyServer

from speller_agent import SpellerAgentFactory
import sys

app = FastAPI(docs_url=None)

Expand All @@ -21,6 +22,16 @@

BASE_URL = os.environ["BASE_URL"]

if not BASE_URL:
ngrok_auth = os.environ.get("NGROK_AUTH_TOKEN")
if ngrok_auth is not None:
ngrok.set_auth_token(ngrok_auth)
port = sys.argv[sys.argv.index("--port") + 1] if "--port" in sys.argv else 3000

# Open a ngrok tunnel to the dev server
BASE_URL = ngrok.connect(port).public_url.replace("https://", "")
logger.info("ngrok tunnel \"{}\" -> \"http://127.0.0.1:{}\"".format(BASE_URL, port))

telephony_server = TelephonyServer(
base_url=BASE_URL,
config_manager=config_manager,
Expand Down
3 changes: 2 additions & 1 deletion apps/telephony_app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vocode==0.1.108
redis
twilio
twilio
pyngrok==6.0.0

0 comments on commit f26d4df

Please sign in to comment.