Fail to Transfer department

Answered

11 Comments

  • Jay
    Comment actions Permalink

    Hi,

    Thanks for the confirmation. It seems that the ids you are passing are correct. 

    However, there could be one possible cause due to the way the script is being written. Note that one of the precondition to transfer the channel is the agent must be in the channel.

    If I understand correctly, the bot makes two requests: send message and transfer department. That could be an edge case when both requests are sent simultaneously. that means when server received transfer department request, the previous request of send message has not been completed.

    so the bot is not in the channel at this point and server would just reject the transfer department request.

    If that is the case, could you please check if you can follow the steps below:
    1 make send message request
    2 wait send message request to be completed
    3 make transfer department request.

    Let me know if it helps :)

    Regards,
    Jay

    2
  • Jay
    Comment actions Permalink

    Hi eLab, 

    From the error message of 'Bad Request', there could be some possible causes:

    - the channel id is invalid, or the channel does not exist

    - the department id is invalid or the department is not online.  

    By looking at your query `channel_id: "${senderId}"`, it seems that you pass the id of the sender instead of the channel. Could you check it? If it does not work, providing the sample ids that you have passed in will help as well. 

    Thanks & Best Regards,
    Jay

    0
  • eLab Asia
    Comment actions Permalink

    Hi Jay, Thank you for your reply.

    I double check with the code that the "senderId" is the channel ID (** Sorry for the bad parameter name).

    Please find below example query for your reference and thank you again for your help in advance.

    {"payload":{"query":"mutation {\n transferToDepartment(\n channel_id: \"W1sibGNJZCIsIiNzdXBwb3J0Y2hhdDo5MjI0NDUzLW5YaFZsRkJxdENQUjhxIl0sWyJzY3JpYmVJZCIsIjE5MDQuOTIyNDQ1My5STjJsdFJoN3JTSHBwIl0sWyJ0eXBlIiwiVklTSVRPUl9DSEFOTkVMIl1d\", \n department_id: \"W1sibG9jYWxJZCIsIjIxNDc1NTkxNjEiXSxbInR5cGUiLCJERVBBUlRNRU5UIl1d\", \n leave: false \n ) { \n success \n } \n }"},"type":"request","id":5}

    0
  • Sergey
    Comment actions Permalink

    Hi Jay!

    Is there any other method to join channel silently, without sending a message?

    Thanks!

    /Sergey

     

     

    0
  • Jay
    Comment actions Permalink

    Hi Sergey,

    I am afraid that there is no support for bot to join channel silently. It would be great if you could let us understand the use case so we can plan and prioritise feature request better.

    Regards,
    Jay

    0
  • Pritesh Raka
    Comment actions Permalink

    Hi Jay,

    Referring to your above answer, Can you suggest me any ideal method to wait for the send_message query to get completed?

    As In
    1 make send message request
    2 wait send message request to be completed
    3 make transfer department request.

    0
  • Bryan - Community Manager
    Comment actions Permalink

    The best example around department transfers is reviewed here:
    Transfer to a department

    It sounds like you want to make the send process more synchronous. Because of the asynchronous nature of working with WebSocket messages, you would have to coordinate synchronization yourself. Is there a particular use case where you need to make sure the transfer has been completed before handling another message?

    0
  • Pritesh Raka
    Comment actions Permalink

    Let's consider the case, when I want to send a big message in a no of small parts, one after another sequentially. What happens here, using promises is not enough to tackle with node.js asynchronous nature. Because, Graph Ql queries take time to execute for which I am not able to figure out any ideal way to track the graph ql responses synchronously. What is ideal method to satisfy my use case?

    0
  • Bryan - Community Manager
    Comment actions Permalink

    Hi Pritesh. To make sure I understand the scenario: you want to send a number of messages back to the user then transfer the chat session to a new department?

    If that's accurate, messages are queued as you send them, so even if you send a number of messages with the last one being a transfer, that order should be maintained in the end.

    If that's not accurate, doesn't fit your needs, or you're experiencing something different let me know and I'll bring in some more expert help. Thanks!

    0
  • Pritesh Raka
    Comment actions Permalink

    Hi Bryan, 

    Consider the case, I am using sendmessage{} mutation to send "a", "b", "c", "d", "e", "f" sequentially, but on the other end, I get them as "a", "c", "d", "b", "e", "f" I hope you get it now. I am not able to make it sequential. Now I expect you to (ignore the transfer department case for now), Kindly guide me first that how should I achieve this synchronous nature in Node.js. There is no specific trigger that I can wait for to detect the completion of previous queries!

    0
  • Bryan - Community Manager
    Comment actions Permalink

    So, as you found out Pritesh, the order of messages sent does not guarantee how they are received.

    This older community post asked about a similar issue. I asked the engineering team if this post's answer is still accurate, and the answer was yes (which may not be the desired answer but is currently how the system is designed).

    https://develop.zendesk.com/hc/en-us/community/posts/360031812613-Sending-Messages-In-Order

    Despite this behavior, I'm hoping this gets you to your next step and sets the expectation on how the system should behave.

    0

Please sign in to leave a comment.

Powered by Zendesk