Chat API Starting an Agent Session

7 Comments

  • Joey
    Comment actions Permalink

    Hi Tarek-

    I haven't seen this specific error before. May I ask if you have looked through our sample application as well? In the meantime I will reach out to our engineers to see if they have any more input.

    0
  • Tarek
    Comment actions Permalink

    Hi Joseph,

    I just looked at the sample code that you have sent and looks like I am doing exactly what startAgentSession function expects, that is, supply as argument my access token. But it is not working.   The sample code that you have provided I tried running it using my ACCESS_CODE and I get the following error:

    {"errors":[{"UUID":"a6063d59-35f8-4dbd-9aa3-f25031bee320","message":"Invalid scope","name":"FORBIDDEN"}],"data":null}

     
    I wonder if my Chat Scope is somehow not set properly? I followed all the OAuth instructions and created the ACCESS_CODE that works in other places. 
     
    Would you please run this command on your end and see if works:
    curl -H "Content-Type: application/json" -X POST https://chat-api.zopim.com/graphql/request -d 'mutation {startAgentSession(access_token: "MY_TOKEN") {websocket_url session_id client_id}}'
     
     
     
    0
  • Joey
    Comment actions Permalink

    Hi Tarek-

    It looks like you have a malformed body in your request, here's the correct one:

    curl -H "Content-Type: application/json" -X POST https://chat-api.zopim.com/graphql/request -d '{ "query": "mutation {startAgentSession(access_token: \"MY_TOKEN\") {websocket_url session_id client_id}}" }'
    

    Reference: https://graphql.org/learn/serving-over-http/#post-request

    Additionally, the request.post.set error seems to originate from not using the right request library.

    As shown in https://codesandbox.io/s/51rorvmwx, we're using superagent (https://github.com/visionmedia/superagent).

    This is is not clear, so we will update our docs.

    0
  • Tarek
    Comment actions Permalink

    Thank you Joseph for addressing the issue. The corrected CURL command works, however, now when I run it, I run into the first error that I mentioned earlier:

    {"errors":[{"UUID":"a6063d59-35f8-4dbd-9aa3-f25031bee320","message":"Invalid scope","name":"FORBIDDEN"}],"data":null}

     

    0
  • Tarek
    Comment actions Permalink

    Also the following error could it be due to the fact that one need Zendesk Enterprise level subscription for Chat features? Please clarify.

    {"errors":[{"UUID":"a6063d59-35f8-4dbd-9aa3-f25031bee320","message":"Invalid scope","name":"FORBIDDEN"}],"data":null}

     

    0
  • Joey
    Comment actions Permalink

    Hi Tarek-

    I'm checking with the team, but most likely yes, this is due to plan type. If I am told otherwise I will let you know.

    0
  • Joey
    Comment actions Permalink

    Hi Tarek-

    In addition to the plan type causing this error, the scope of the OAuth token may be the cause as well. It should have the scope of read write chat.

    0

Please sign in to leave a comment.

Powered by Zendesk