How get customerid for create guest session with API

I'm trying to use this API: /api/v2/knowledge/guest/sessions
but I can't figure out how to put the customer id and context in the body.
this is the body : {
"app": {
"deploymentId":"XXXXX",
"type" :"MessengerKnowledgeApp"
},
"customerId": "?????",
"contexts": [
{
"id": "?????"
}
]
}

I tried to create a websoket connection as indicated in this documentation :
Web messaging Guest API (genesys.cloud)
but I still have a 403 error

Hi,

A 403 error means you are not authorized to perform the requested action. Ensure you have the correct permissions to perform the requested actions and that you are authenticated successfully. Also try to turn on the Feature Toggle or fix the configuration.

Regards,
Declan

1 Like

Hi,

403 error means that provided parameters are invalid.
Make sure that you're using a valid deploymentId when opening the websocket.
Also, verify the domain configuration.
Check if the domain has to be provided or not in your deployment settings. If, required, is it configured in your client ? Does it match what is expected ?
If you enforced domain check, you have to set the origin header accordingly in your request.
See picture below.
image

You may want to test manually the websocket connection with wscat:

wscat -o <your domain> -c "wss://<server_address>/v1?deploymentId=<your deploymentId>"

Regards,
V.P.

1 Like

Thank you very much by opening to everyone I was able to open the connection. I want to know how to get a customer id?

Nice to know you succeeded.

CustomerId is a string and you're free to use whatever (unique) id suits your need.
Usually, it's a uuid but not necessarily.

You may want to check the Api resource page:
POST /api/v2/knowledge/guest/sessions

Regards,
V.P.

1 Like

Thank you for your answers, it helps me a lot. How can I retrieve the context id of my session?

Hi,

My understanding is that these are your data in the context structure.
It's not strongly typed in the Api and the doc does not detail them, so my guess is that you don't need them in first place :slight_smile:
But I could be wrong.
I would leave them empty for the time being with something like "contexts": [{}]

Schema:

  "contexts": [
    {
      "id": "",
      "values": [
        {}
      ]
    }
  ]

Example:

  "contexts": [{
    "id": "99999999-9999-9999-9999-999999999999",
    "values": [{
      "id": "00000000-0000-0000-0000-000000000000"
    }]
  }]

Regards,
V.P.

1 Like

Hi vpirat,

Thank you for your help.
It works well with the format you gave me.

it also possible to use this body :

{
"app": {
"deploymentId":"99999999-9999-9999-9999-999999999999",
"type" :"MessengerKnowledgeApp"
},
"customerId": "00000000-0000-0000-0000-000000000000"

}

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