Zendesk - How to detect if I Change (before submit) Requester Name in opened Tickets? - zendesk

I have a server side app, which display customer info such as name, id, email etc based on currently opened ticket.
My next task is to update the Requester name in Zendesk App ( server side app ) if i made changes in Ticket Requester before submit.
is that possible?

You can add custom events using client.on('event_type', handler). Refer to ZAF Client API for available events depending on the location.
Here is an example:
if (client) {
client.on('ticket.requester.name.changed', function(e) {
document.getElementById('requesterNameElementId').innerText = e;
});
} else {
console.log('ZAF Client only works within Zendesk iFrame');
}

Related

Issue with IAccessTokenProvider on iOS devices

In my Blazor WebAssembly, I call the API to fetch some data. The user must be authenticated against the Identity Server. In the header of the request, I add the user token.
In the page, the user has to select some dropdown list and then press the submit button. On the click, the application calls the API with the following function (the result conversion is omitted).
private readonly IAccessTokenProvider _accessToken;
public APIService(HttpClient httpClient, IAccessTokenProvider accessToken)
{
_httpClient = httpClient;
_accessToken = accessToken;
}
public async Task<APIResponse> GetAttributeAsync(APIRequest apirequest)
{
var tokenResult = await _accessToken.RequestAccessToken();
tokenResult.TryGetToken(out var token);
HttpRequestMessage request = new HttpRequestMessage(
HttpMethod.Post, $"typing");
request.Headers.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue(
"Bearer", token.Value);
// ...
return APIResponse;
}
Then, it hides the form and display the result from the API. There is a back button, that hides the result and shows again the form.
The web application is working fine as I expected. Then, I wanted to try the web application on iOS (iPhone or iPad). I fill the form, submit the request and display the data as expected. Then I click the button to display again the form and send another request: when I sent the request, the function above generates an error
Arg_NullReferenceException
If I refresh the page, the web application is working again. The behaviour is consistent in iOS with Safari, Edge and Chrome.
I guess, for some reasons, the RequestAccessToken() is not able the second time to retrieve the user token.
Have someone else had this issue? How can I fix it?
Update
After a day of testing, what I can say is that on Windows the function RequestAccessToken() finds the token every time I ask to retrieve it. On iOS devices, the application can read the token only once and then the token is removed. I don't know if it is correct, but I added a small cache in the Local Storage to save the token and reuse it.
Is it the correct way to approach the problem?

Zendesk Chat widget status check

I am using the Zendesk chat widget on my web portal. My requirement is whenever the widget goes down from server "Zendesk site" check the status and send notification to site owner.
On the research I found the $zopim.livechat.setOnStatus(callback); method. But the disadvantage of this gives only the offline and online status.
The "Status" that is checked with the callback function setOnStatus will only ever refer to the actual chat status rather than a technical health check status.
It's a little clunky, but if you're expecting the widget to load, but it doesn't due to the service being down, you could do a manual check after a given time, and have a reporting callback (Dummy function your_error_callback):
// Check Zopim (Zendesk Chat) status after 10 seconds
var ZopimHealthCheck = setInterval(function () {
if (window.$zopim === undefined || window.$zopim.livechat === undefined) {
your_error_callback("Zendesk Chat not available");
}
clearInterval(ZopimHealthCheck);
}, 10000);

Twilio chat client channels list

I am trying to create a simple chat app between 2 users, using twilio js api.
The idea is that I know that two users will have to chat with each other, and I want to create a channel specifically for the chat between them both.
So when a user logs in, I want to search the channel by it's name:
if it exist already, it means that the other user is already logged, and I want to join this channel.
else, I want to create a channel by this specific name, and wait for the other user.
I tried 2 alternatives:
1. chat client.
2. IPMessaging client.
I am trying to user this function:
chatClient.getChannels().then(function (channels){ // search for the channel I need // }
But for chat channel I get the following error:
twilio TypeError: chatClient.getChannels is not a function
So with an IPMessaging client it all works well, but I can't trigger events of user typing, which are important for my app:
chatChannel.on('typingStarted', function(){
console.log('user started typing')
});
chatChannel.on('typingEnded', function(){
console.log('user stopped typing')
});
Should this events be possible to trigger for IPMessaging Client?
If not, how can I get the channels list for a chat client?
Thank you
You can trigger typing indicators with IPMessaging (Programmable chat):
https://www.twilio.com/docs/api/chat/guides/typing-indicator
//intercept the keydown event
inputBox.on('keydown', function(e) {
//if the RETURN/ENTER key is pressed, send the message
if (e.keyCode === 13) {
sendButton.click();
}
//else send the Typing Indicator signal
else {
activeChannel.typing();
}
});
That same event can be triggered for members, and not only channels.
https://media.twiliocdn.com/sdk/js/chat/releases/0.11.1/docs/Member.html

Slack deep link into client: how to link into im if im not open

I made a platform-independent contactlist-style standalone client for Slack in Qt/C++.
It uses Slack's Deep Linking scheme to navigate through the official Slack-Client when clicking Items in my ContactList.
The problem is, when clicking a user item in my list (which gets the user id and creates the link), the slack client will only enter the im dialog, if it was open before (if i have a im history with that user).
Otherwise it will just show the team directory context for that user, where i manually have to click "message" to actually enter the chat dialog.
Is there really no way to do it right just with slack:// deep links?
The only solution that i can think of right now is to open a new im, if not exist, using api call from my application before opening the link. or maybe open im's for all users at app launch.
But that's kind of a dirty workaround, that i don't like.
Is there a more elegant way to go directly to a new IM than this?
EDIT: quick Workaround without error handling is working this way:
void Window::contactListDoubleClicked(QTableWidgetItem *item)
{
QString id = listWidget->item(item->row(),1)->text();
int type = listWidget->item(item->row(),3)->text().toInt();
if (type == 1) { // if item is a user, we have to ensure that im exists by requesting im.open
QEventLoop eventLoop;
QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
QNetworkRequest req(QUrl(QString("https://slack.com/api/im.open?token=").append(m_token).append("&user=").append(id)));
QNetworkReply *reply = mgr.get(req);
// block stack until reply is ready
eventLoop.exec();
qDebug() << reply->readAll();
QDesktopServices::openUrl(QUrl(QString("slack://user?team=XXXXXXXX&id=").append(id),QUrl::TolerantMode));
} else {
QDesktopServices::openUrl(QUrl(QString("slack://channel?team=XXXXXXX&id=").append(id),QUrl::TolerantMode));
}
}

Rails and Websockets: need some direction on a feature

In my rails app a User has a profile and this profile can be publicly accessible. I have been looking at using the Pusher gem (https://github.com/pusher/pusher-gem) to use for plug-and-play websocket usage with my app.
Basically I am wanting it so that if a user is looking at a public profile and the owner of that profile happens to update that profile then the front-end is updated with the new information and the user is notified on the front-end about the update.
Any help on where to get started would be great!
For each public profile have a unique channel name e.g. <user_name>-profile.
Whenever an updated occurs on the user user_name's profile trigger an event on the user's channel, passing the updated data.
data = update_profile()
Pusher.trigger( '<user_name>-profile', 'profile-updated', {:profile => data} )
On the profile page running the the browser have the code that listens to updates only on the relevant channel:
var pusher = new Pusher( APP_KEY );
var channel = pusher.subscribe( '<user_name>-profile' );
channel.bind( 'profile-updated', function( update ) {
// Update UI to show new profile information
// Show something to indicate that an update has occurred
} );
The one problem here is that you will be triggering an event even when nobody is viewing the public profile. If you wanted to fix that you would need to use WebHooks and keep track of whether or not a profile channel was occupied and only trigger the event if it is.

Resources