Skip to main content

Create Stream

API create stream dùng để khởi tạo cuộc gọi từ PSR, cho phép thiết lập websocket server linh động theo từng cuộc gọi, cho phép tích hợp nhiều voicebot khác nhau trên cùng một tenant.

curl --location 'https://{{base_url}}/psr/v1/call/stream' \
--header 'Authorization: Bearer {{token}}' \
--form 'url="wss://demo-psr.ws/server/ws"' \
--form 'destination="0899999999"' \
--form 'app="bot"' \
--form 'audio_file=@"audio/audio.wav"' \
--form 'is_silence="true"' \
--form 'channel="mono_a"'
--form 'parameter="{\"value\":\"test\"}"'

Form Data

KeyDescriptionRequired
urlUrl tương đối hoặc tuyệt đối nơi kết nối WebSocket sẽ được thiết lập.x
destinationSố điện thoại hoặc extension được gọi tớix
appCó 2 app hiện tại: (Mặc định là dial)
- dial: Thực hiện cuộc gọi tới extension, sau khi kết nối sẽ tiến hành dial tới destination.
- bot: Thực hiện cuộc gọi tới destination, stream và phát file âm thanh.
channelKênh thoại dùng cho stream, mặc định sẽ là stereo (2 kênh).
- stereo: Stream cả 2 kênh.
- mono_a: Chỉ stream kênh thoại của đầu người gọi.
- mono_b: Chỉ stream kênh thoại của đầu người nhận. (Done)
extensionDùng cho app dial. Extension của tổng đài.x (khi dùng app dial)
is_silence(true, false) Dùng cho app bot. Phát file silence sau khi kết nối tới destination. Dùng is_silence=true khi bạn không cần bot phát file âm thanh khi kết nối cuộc.
audio_file(file) Dùng cho app bot. Phát file sau khi kết nối tới destination. Nếu is_silence=true audio_file sẽ được bỏ qua.
parameterMetadata cần truyền đến bot khi thiết lập cuộc gọi.
Ví dụ: {"danh_xung":"anh"}

Response trả về:

{
"code": "OK",
"data": {
"call_id": "60fb0716-87cf-437a-91e6-cdcecae21b43",
"full_recording_url": "https://{{base_url}}/psr/v1/call/record/full_60fb0716-87cf-437a-91e6-cdcecae21b43.wav",
"recording_url": "https://{{base_url}}/psr/v1/call/record/60fb0716-87cf-437a-91e6-cdcecae21b43.wav",
"status": "in-progress"
},
"message": "OK"
}