Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a call and add stream audio programmatically? #258

Open
prateeksachan opened this issue Feb 12, 2024 · 0 comments
Open

How to create a call and add stream audio programmatically? #258

prateeksachan opened this issue Feb 12, 2024 · 0 comments

Comments

@prateeksachan
Copy link

prateeksachan commented Feb 12, 2024

Hi,

I'm looking for an example to:

  1. Create a call
  2. Stream audio

From the docs, it seems plivo takes in an answer_url to create a call and for creating a stream I need call_uuid. But since I'm already creating a call, I'm not getting any call_uuid. Below is what I've tried as of now:

async def make_call():
    plivo_client = plivo.RestClient('auth_id', 'auth_token')
    response = plivo_client.calls.create(
        from_='from_number',
        to_='to_number',
        answer_url=f"{app_callback_url}/plivo_callback?ws_url={websocket_url}",
        answer_method='POST')


@app.post('/plivo_callback')
async plivo_callback(request: Request, ws_url: str, CallUUID: str):
    websocket_plivo_route = f'{ws_url}/ws/'
    response = plivo_client.calls.start_stream(call_uuid=CallUUID,
                                         service_url=websocket_plivo_route, bidirectional=True)

I have a server running and listening to /ws/ websocket endpoint.

The initial call get created with the response:

{'api_id': '34e56af1-739d-4b54-9861-613a2db7546d',
 'message': 'call queued',
 'request_uuid': '1b08512d-3fff-4b4d-ada2-c956cdaa70b1'}

And I get Exception occurred in plivo_callback: Stream consumed as the exception and the call gets disconnected shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant