Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Guest chat usage

    Posted 06-05-2025 18:18

    Arthur_Bianchini | 2020-04-20 20:13:44 UTC | #1

    Hi all,

    I am trying to create a web chat using a third part application.

    First of all I created a chat using the url below:

    POST /api/v2/webchat/guest/conversations.

    The request body:

    { "organizationId": "IdofMyOrg", "deploymentId" : "Deploymentid", "routingTarget" : { "targetType" : "queue", "targetAddress": "bbfa456c-2617-4fea-89f8-2be722930a71" }, "memberInfo" : { "displayName" : "Edson teste", "avatarImageUrl": "https://www.familysearch.org/blog/pt/wp-content/uploads/sites/6/2017/06/google.jpg", "customFields" : { "somefield" : "arbitrary data", "anotherfield" : "more arbitrary data" } } }

    second step was sending a message using the response:

    POST https://api.mypurecloud.com/api/v2/webchat/guest/conversations/3ba4fee3-4a00-4d72-b080-772eebc6dd27/members/da410cc0-8371-468e-826c-b1f5bdcff8c3/messages

    the response that I received from the server was:

    { "message": "Conversation State", "code": "chat.error.conversation.state", "status": 400, "messageWithParams": "Conversation State", "messageParams": { "message": "The conversation is not active" }, "contextId": "9cfabc07-bd3c-4119-ada9-88f135942b2e", "details": [], "errors": [] }

    When I sent the request to create a web chat I got a success response but the session is not created on the Agent IDE of Pure Cloud.

    If any other clarification is necessary please advise.

    Best Regards.


    crespino | 2020-04-20 21:06:33 UTC | #2

    Two things...

    1. In your request to /api/v2/webchat/guest/conversations the routingTarget.targetAddress needs to be the queue name, not the GUID.
    2. According to the docs, it appears that after you create the chat, you have to actually establish the Websocket connection to activate it:

    Important Note

    The chat will not be routed to an agent until the WebSocket is connected. POST /api/v2/webchat/guest/conversations creates the conversation object, but does not place the conversation in queue until after the guest's WebSocket has connected. This is a safeguard to ensure a chat does not connect to an agent until the customer has connected to the chat and is ready to receive messages.

    I'd check both of those first. Let us know if you continue to have trouble.


    crespino | 2020-04-20 21:37:09 UTC | #3

    One update, I was correctly by the product team that GUIDs are acceptable to assign in the routingTarget.targetAddress field.

    So, I would focus on setting up that Websocket to actually activate the chat.


    Arthur_Bianchini | 2020-04-22 13:45:31 UTC | #4

    Hi,

    There's no way we can establish a connection without creating a Websocket ?

    I am asking because we do not have control from the client side. We are using a middleware service to try to establish a connection between client and Pure Cloud chat service.

    If there's no other way, do you have any examples and genesys docs of how to establish a connection using websocket and the pure cloud chat API ?

    Tks in advance


    anon39326996 | 2020-04-22 14:18:59 UTC | #5

    Can you clarify what you're trying to accomplish? If you're using a third party chat and want these chats to be routed to agents, then 3rd party APIs are appropriate and no web socket is required. Guest chat APIs are for using our chat for consumers to chat with agents.


    Arthur_Bianchini | 2020-04-22 14:56:41 UTC | #6

    Lucie,

    We are creating a middleware service that receives messages from a client that we do not have control and send to a queue that will be derived to an Agent accordingly.

    Using only the Guet chat API's without creating any websocket connection we received the error mentioned above. Could you please tell us why ?

    Another question: we were able to create a chat interaction but we were not able to see the message list box on agente screen, using the /api/v2/conversations/chats.

    What's the difference between these two API's ? there's a way to send messages to an Agent using the conversations API's instead of the guest API's ?

    Tks in advance


    crespino | 2020-04-22 20:11:52 UTC | #7

    Arthur,

    Using /api/v2/conversations/chats is meant to be used to route a 3rd party chat to an agent. As an example, let's say you were using Genesys for voice calls, but some other vendor for chats. If you wanted to "blend" these two system you can use the Conversations API to submit a chat conversations, along with the 3rd parties chat identifier as a payload. That "chat" would go to an agent, but it would not be a normal chat and it wouldn't have a UI. Instead that conversation could invoke the 3rd party agent chat UI and pass in the chat identifier from the 3rd party to launch the 3rd party chat UI. I really don't think that is what you are trying to do in your use case.

    The Guest Chat API is really what you need to use and unfortunately establishing that websocket is the only way to make it work. Your middleware would need to create the chat and then establish and maintain the websocket for as long as that chat is active. Your middleware would then act as a proxy between the consumer chat UI and the agent, sending messages back and forth.


    tim.smith | 2020-04-24 14:10:37 UTC | #8

    Arthur_Bianchini, post:6, topic:7579
    Using only the Guet chat API's without creating any websocket connection we received the error mentioned above. Could you please tell us why ?

    Because a websocket is required for a guest chat, the chat conversation won't be routed or handled until the client makes a connection to the websocket. This prevents bogus chat conversations where there's no customer from reaching agents. There is no alternative; the websocket connection is mandatory.


    system | 2020-05-25 14:10:39 UTC | #9

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


    This post was migrated from the old Developer Forum.

    ref: 7579