open source
This commit is contained in:
parent
70b6e17c69
commit
a93bfc1ec9
61 changed files with 4013 additions and 126 deletions
29
vocode/streaming/telephony/server/router/twiml.py
Normal file
29
vocode/streaming/telephony/server/router/twiml.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from vocode.streaming.telephony.templates import Templater
|
||||
|
||||
|
||||
class TwiMLRouter:
|
||||
def __init__(
|
||||
self,
|
||||
base_url: str,
|
||||
templater: Templater,
|
||||
logger: Optional[logging.Logger] = None,
|
||||
):
|
||||
super().__init__()
|
||||
self.base_url = base_url
|
||||
self.templater = templater
|
||||
self.logger = logger or logging.getLogger(__name__)
|
||||
self.router = APIRouter()
|
||||
self.router.add_api_route(
|
||||
"/twiml/initiate_call/{id}", self.call_twiml, methods=["POST"]
|
||||
)
|
||||
|
||||
def call_twiml(self, id: str):
|
||||
return self.templater.get_connection_twiml(base_url=self.base_url, call_id=id)
|
||||
|
||||
def get_router(self) -> APIRouter:
|
||||
return self.router
|
||||
Loading…
Add table
Add a link
Reference in a new issue