Recent searches
No recent searches
Chat session cannot be routed to chatbot agent using Conversation API updateAgentStatus
Posted Jan 22, 2021
I currently implement a chatbot in our help center based on Google’s Dialogflow technology. This works already well, when I put myself as a chat agent into the department I want to use for the chatbot. However, if I remove myself from this department and put any other agent into it, the chat widget stays in offline mode, so that a user cannot start a chat.
Here is the relevant code for this issue.
Help Center:
window.zESettings = {
webWidget: {
chat: {
departments: {
enabled: ['NI Service Bot']
}
},
contactForm: {
suppress: true
},
helpCenter: {
suppress: true
}
}
};
Conversation API (Node JS):
if(type === 'updateAgentStatus'){
graphQlQuery = {
payload: {
query: `mutation {
updateAgentStatus(status: ONLINE) {
node {
display_name
id
name
}
}
}`
},
type: "request",
id: REQUEST_ID.UPDATE_AGENT_STATUS
};
logMessage = "[updateAgentStatus] Request sent";
}
webSocket.send(JSON.stringify(graphQlQuery));
console.log(logMessage);
However, when I log the data coming back, I always see that it uses my account for this graphQL query and not the one from the agent I put into the chatbot department. How can I change this?
I have seen a comment from Bryan here that might indicate that it matters under which Zendesk account the OAuth access token was created:
https://develop.zendesk.com/hc/en-us/community/posts/360051528933
Does this mean I need to log in with the chatbot credentials and generate a new OAuth token then? I was under the impression that an OAuth token is not user-specific and if so, I would expect to see some information in the Chat console about the user who has created the OAuth token.
Thanks for any help pointing me in the right direction!
0
4 comments
Greg Katechis
Hi Marius! A chatbot needs a dedicated agent seat in order to function, so you will need to associate the bot with a "bot agent". Once you associate the credentials with that agent, you'll be good to go.
0
Marius Wilhelmi
Hi Greg,
thanks for your swift reply.
I already have a dedicated Zendesk agent licensed assigned to my chatbot. I am not yet sure what you mean exactly by "associate the credentials with that agent". I am using the "Client credentials grant type" as described on this page:
https://developer.zendesk.com/rest_api/docs/chat/auth
It says on this page about the password grant type: This grant type is only supported on Chat-only accounts. It's not supported on Chat+Support accounts. Since we have a Chat+Support account, the password type does not seem to be possible. Is this the workflow you are referring to? I do not see though where I associate the credentials with the chatbot agent.
0
Marius Wilhelmi
I have now tried to create another Chat API token while signed in with the chatbot agent credentials. Interestingly, one agent cannot see the tokens of another agent, so even when I am signed in as the Zendesk owner, I cannot see a token created by the chatbot agent, which I find a bit worrisome in regards to missing transparency.
However, the client id and client secret from the chatbot account return a 401 - invalid_client error. I switched the tokens several times and verified that the one created from my own Zendesk account work and the other one doesn't. Here is btw. part of the code I used for authorization:
0
Greg Katechis
To provide an update here for anyone that comes across this in the future:
The issue that we were running into had to do with the "client_type" having been set to public, when it needed to be set to confidential. Additionally, our docs are a bit ambiguous about the ID that needs to be used to make the API calls, so I'll be working to get those updated as well!
0