As soon as server opened, client(genesys) sends back closed for audiohook integration

[14:55:29.430] INFO: incoming request
reqId: "req-1"
req: {
"method": "GET",
"url": "/api/v1/audiohook/ws",
"hostname": "60c9-106-196-17-159.ngrok.io:443",
"remoteAddress": "127.0.0.1",
"remotePort": 62093
}
[14:55:29.434] INFO: Websocket Request - URI: </api/v1/audiohook/ws>, SocketRemoteAddr: 127.0.0.1, Headers: {
"host": "60c9-106-196-17-159.ngrok.io:443",
"user-agent": "GenesysCloud-AudioHook-Client",
"accept-encoding": "gzip",
"audiohook-correlation-id": "eb20b96d-391e-4222-affe-f943b51afe25",
"audiohook-organization-id": "3ecf285f-2d3f-4aed-86f2-2011b404ca77",
"audiohook-session-id": "8065cc42-eab4-47ca-a01d-8f6a65721e83",
"cache-control": "no-cache",
"connection": "Upgrade",
"pragma": "no-cache",
"sec-websocket-key": "mmWbDu1TidioS/25JUv1CQ==",
"sec-websocket-version": "13",
"upgrade": "websocket",
"x-api-key": "SGVsbG8sIEkgYW0gdGhlIEFQSSBrZXkh",
"x-forwarded-for": "34.218.126.12",
"x-forwarded-proto": "https"
}
reqId: "req-1"
[14:55:29.771] DEBUG: onOpenMessage - {
"version": "2",
"id": "8065cc42-eab4-47ca-a01d-8f6a65721e83",
"type": "open",
"seq": 1,
"position": "PT0S",
"parameters": {
"organizationId": "3ecf285f-2d3f-4aed-86f2-2011b404ca77",
"conversationId": "00000000-0000-0000-0000-000000000000",
"participant": {
"id": "00000000-0000-0000-0000-000000000000",
"ani": "",
"aniName": "",
"dnis": ""
},
"media": [
{
"type": "audio",
"format": "PCMU",
"channels": [
"external",
"internal"
],
"rate": 8000
},
{
"type": "audio",
"format": "PCMU",
"channels": [
"external"
],
"rate": 8000
},
{
"type": "audio",
"format": "PCMU",
"channels": [
"internal"
],
"rate": 8000
}
],
"language": null,
"customConfig": {}
},
"serverseq": 0
}
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:29.772] INFO: onOpenMessage - Selected media: {"type":"audio","format":"PCMU","channels":["external","internal"],"rate":8000}
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:29.772] INFO: onOpenMessage - Open handlers complete, session opened
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:29.772] DEBUG: sendMessage - {"version":"2","type":"opened","id":"8065cc42-eab4-47ca-a01d-8f6a65721e83","seq":1,"clientseq":1,"parameters":{"media":[{"type":"audio","format":"PCMU","channels":["external","internal"],"rate":8000}],"startPaused":false}}
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:30.103] DEBUG: onCloseMessage - {
"version": "2",
"id": "8065cc42-eab4-47ca-a01d-8f6a65721e83",
"type": "close",
"seq": 2,
"position": "PT0S",
"parameters": {
"reason": "end"
},
"serverseq": 1
}
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:30.103] INFO: onCloseMessage - Closing session (state: ACTIVE)...
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:30.103] INFO: onCloseMessage - Close handlers completed, session closed
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:30.103] DEBUG: sendMessage - {"version":"2","type":"closed","id":"8065cc42-eab4-47ca-a01d-8f6a65721e83","seq":2,"clientseq":2,"parameters":{}}
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:30.440] INFO: onWsClose - Websocket closed. Code: 1000
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:30.441] INFO: Session statistics - start: 2023-09-14T09:25:29.434Z, open: PT0.338S, close: PT0.669S, received: 738, sent: 335, pos: {start: PT0S, end: PT0S}, audio: {duration: PT0S, discarded: PT0S, paused: PT0S}
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"
[14:55:30.441] INFO: onWsClose - All fini handlers completed, changed state to DISCONNECTED
reqId: "req-1"
session: "8065cc42-eab4-47ca-a01d-8f6a65721e83"

session is getting closed immediately with in a fraction of seconds once it got opened without any error, please can you tell me any reason for this why this is happening,

Also I am following the code(GitHub - purecloudlabs/audiohook-reference-implementation: Open-source repo to host our Audiohook reference application).

in this for handling message this is present in serversessionimpl.ts

    this.ws.on('message', (data, isBinary): void => {
        try {
            if (isBinary) {
                this.onBinaryMessage(data);
            } else {
                this.onTextMessage(Buffer.from(data).toString('utf8'));
            }
        } catch (err) {
            this.logger.error(`Error processing message: ${normalizeError(err).stack}`);
            this.signalError('Internal server error');
        }
    });
    this.ws.on('error', (error: Error) => {
        this.logger.error(`Websocket error, forcing close (SessionState: ${this.state}): ${error.stack}`);
        this.ws.close();
    });

when I start a call, streaming data does not comes to server too.

Hello,

As I see you are receiving conversationId and id attributes with a value of "00000000-0000-0000-0000-000000000000", this corresponds to Audiohook Connection Probe.
When you save/update your Audiohook integration configuration, this will trigger a Connection Probe from Genesys Cloud to your Audiohook server, to check that connection is valid, up and ready to accept ws sessions.

Regards,

You need to enable recording on your Genesys Cloud Voice Trunk or BYOC Cloud Trunk .
Line Recording must be enabled, Dual Channel must also be enabled using one of the following audio formats (audio/PCMU, audio/PCMA, audio/L16, audio/opus)

You also need to request the transcription to start, via configuration or via the Architect flow.
Via configuration, at Queue level, you can enable voice transcription for the voice channel
Or you can request it from an Architect flow using the Transcription action .

Your call must involve an external participant. The call must go through Trunk/Edges (e.g. call from the PSTN/Telephony network to Genesys Cloud).
An internal call (e.g. made by a Genesys Cloud user from his Desktop/phone) will NOT trigger an audiohook session.

Regards,

Hi I have enabled voice transcription action at the start of the IVR flow.
I have enabled recording but still nothing happened

Is there an alert/warning/red icon on your Audiohook Monitor integration (Genesys Cloud Desktop - Admin - Integrations - Integrations -> when viewing the list of integrations)? Which would mean that Connection Probe check was not successful. If it is not considered as successful, no audiohook sessions will be started.

When you say you have enabled recording, do you mean that Recording is enabled in your Trunk, and that Dual Channel is also enabled?

Is Voice Transcription enabled (Genesys Cloud Desktop - Admin - Quality - Speech and Text Analytics -> Voice Transcription set to "Enabled based on Queue configuration or Flow action")?

How are you testing? Are you making a call from a regular phone (not a Genesys phone - a mobile or office phone) to a Genesys Cloud DID number?

Regards,

I didnt see any alert/warning/red icon on integrations. It says integration is set to 'ACTIVE'.
yup Recording is enabled in trunk
Voice transcription too enabled
Yes I am testing from my mobile

I don't know then. I mean nothing I can add - we do not have access to your org's data via the forum to be able to troubleshoot this.
Please open a case with Genesys Cloud Customer Care to investigate the issue.

Regards,


I have enabled Flow transcription at the start of the flow
trunk named test is set to enabled for recording

these are the trunk settings

voice transcription too enabled
can you please let me know where i have missed

1 Like

Remove /disable"Require user consent before recording" on your Trunk.
Recording will not start until consent is given - and audiohook is relying on recording to be active.

A side comment:
What type did you use for your Trunk? "BYOC Carrier" (BYOC Cloud add-on)?
That must be the type you use (BYOC Cloud) is not using the Genesys Cloud Voice AWS Trunk.
Audiohook is not supported with BYOC On-Premise (Premise Edges).

If it is indeed a BYOC Carrier trunk, make sure to create an Outbound Route with this Trunk on your default Site.
Right now, your trunk shows a suqare/cross icon - which means it is not associated with a site.

Regards,

sorry I didnt get it can you please elloborate it

Here in trunk it shows

Your screenshot was showing 2 Trunks.
One is named "PureCloud Voice - AWS" - it is the one created out of the box when Genesys Cloud Voice (Genesys numbers) are used.
The other one is named "test". A trunk that you created. SO I have no idea what's in it.

What I am trying to say is that you should know what Trunk is used/triggered when making a call from external to Genesys Cloud - what you have setup for telephony access.

The comments I made on enabling recording, enabling dual channel and disabling "Require user consent before recording" are to be applied to the Trunk you are using for your telephony access (something that I can't know).

I don't understand your question.

From audiohook perspective, the audio is sent via the websocket as binary data.

I don't know if you have code that displays a trace (console logs) when binary data is received (and you removed this from the post above), or if you're saying you are not receiving the audio stream, or if you are saying you don't know what your code does with the captured stream.

If you're saying you are not receiving the audio stream, you can try to deactivate the audiohook integration, wait a couple of minutes, and activate it again.
If it is not enough to solve, you can open a ticket with Genesys Cloud Customer Care. We do not have access to customer data and can't investigate it from this forum.

Regards,

finally I got a .wav file. Now I have changed audio to text by using speech service in code. Now can I send back some text or a response as an audio through an audiohook and send that back to the user, is it possible through audiohook

Hello,

No, it is not possible at this time to send the transcript back to Genesys Cloud. It will have to be stored on your side.

I think it is planned to implement this in the future using Audiohook events. But at this time, nothing is available, nor has been defined - no event entity types defined at this time.

Regards,

So audiohook right now can only be used just like triggering other service which is one way. is it correct?

thankyou for your responses.

Correct. Right now, only audio streaming from Genesys Cloud to 3rd party websocket server is possible.

Does in EVTS, can i train custom vocabulary for example dinosaur names or any product names that are specific. so that when user asks it, it can able to recognise that product names.

thanks.

Hi am getting
{
type: 'audio',
format: 'PCMU',
channels: [ 'external', 'internal' ],
rate: 8000
}
Is there is any possibility that I can get data stream in this format WAV (16 kHz or 8 kHz, 16-bit, and 1)
Because Azure Speech to text service is only supported one is WAV (16 kHz or 8 kHz, 16-bit, and mono PCM).
so I want to use the same.