Genesys socket alway returning request invalid

I followed the steps outlined in https://developer.genesys.cloud/commdigital/digital/webmessaging/websocketapi and I continuously get: {"type":"response","class":"string","code":400,"body":"Request invalid"}

I have set up my messenger, messenger deployment, and my message flow. I am able to connect to the websocket, but I am unable to communicate because I get the 400 error every time I sen a message.

When the websocket is connected, I send:

{
  "action": "configureSession",
  "deploymentId": deploymentId,
  "token":  token
}

Even for this, I get 400 error message.

Hi Jorge,

Make sure to send string values for json attributes.
Do not insert linefeed/carriage return.
Your request should be:

{ "action":"configureSession", "deploymentId":"deploymentId", "token":"token" }

Regards,
V.P.

I do send the values, I just did not want to post them here.

I also tried the javascript sdk and I get the same error. No description of what the issue is. I copied the example online (https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudjavascriptGuest/) and I get the same gad request error.

Is is very frustrating when the documentation does not match the code: GitHub - MyPureCloud/purecloud-guest-chat-client-javascript at 34b31ba1890cd3f028240f838618765a90d20ce7

@Jorge_Diaz are you trying to use web chat or web messaging? Your original post links to web messaging docs, but your last two comments link to the web chat v2 SDK. Web chat and web messaging are different offerings with no overlap in APIs/tooling. There isn't a JavaScript SDK for web messaging.

I am trying to use Web messaging Guest API (https://developer.genesys.cloud/commdigital/digital/webmessaging/websocketapi#):
I pass this and get 400.

{
  "action": "configureSession",
  "deploymentId": "9e26ee99-369a-4b6a-81a9-9144b3c84914",
  "token":  "00000000-0000-0000-0000-000000000000"
};

Can you share some of your code showing how you're preparing and sending the message across the websocket?

As a general tip for testing websockets, you can connect to a testing service to see what exactly your client is sending. This can be helpful to see what the server is receiving to troubleshoot formatting errors. Of course, be careful not to send any sensitive information, like passwords or PII, to 3rd party services. One such service is Online Websockets Tester - Debug Client Tool.

Hi Jorge,

Few things:

  • You must use consistent values across messages.
    When you open a websocket connection with a deploymentId, you must use the same deploymentId for the connection lifetime.
    I could see that the deploymentId used for opening the connection is not the same one when sending the configureSession.

As Tim mentionned, you may want to use some external tool, online or not.
wscat allows you to test interactively and easily.
npm install -g wscat

Example:
wscat -c "wss://<server_address>/v1?deploymentId=xxxx-xxxx-xxx-xxx-xxxx"
{"action":"configureSession", "deploymentId":"xxxx-xxxx-xxx-xxx-xxxx", "token":"<unique_identifier>" }

  • The deploymentId used for opening the connection is a valid one.
    The one used for configuring the session is not.

  • Testing manually will allow you to validate your config as well.

Hope this helps,

Regards,
V.P.

Hi,

Wondering if you were able to sort this out ?

Regards,
V.P.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.