How to play sound instead of dial tones - dialogflow-cx

I have a bot in Dialogflow CX with Voximplant. I want to play a typing sound while my customer is waiting for response. How do I do it?

To do this:
require(Modules.Player);
let typing = false;
var typingPlayer = VoxEngine.createURLPlayer('https://staging.crmsuite.com/media/typing.trimmed.mp3',{loop:true,progressivePlayback:true});
conversationParticipant.addEventListener(CCAI.Events.Participant.Response,function (e) {var res = e.response||{};
if (!typing && res.recognitionResult?.messageType === "TRANSCRIPT" && res.recognitionResult?.isFinal) {
typingPlayer.sendMediaTo(call);
typing = true;
}
if (res.automatedAgentReply?.responseMessages) {
res.automatedAgentReply.responseMessages.forEach((response) => {
if (response.liveAgentHandoff) transfer = true;
if (response.endInteraction && res.replyText) hangup = true;
else if (response.endInteraction) endConversation();
});
}
}
);
conversationParticipant.addEventListener(CCAI.Events.Participant.PlaybackReady,(e) => {
if(typing) {
conversationParticipant.sendMediaTo(call);
typing = false;
}
});

Related

how to connect to specific wifi in xamarin ios?

I want to connect to wifi....................................................................
Here is my code:
NEHotspotConfigurationManager wifiManager = new NEHotspotConfigurationManager();
var wifiConfig = new NEHotspotConfiguration(ssid, password, false) { JoinOnce = true };
wifiManager.RemoveConfiguration(ssid);
wifiManager.ApplyConfigurationAsync(wifiConfig);
wifiManager.ApplyConfiguration(wifiConfig, (error) =>
{
if (error != null)
{
Console.WriteLine($"Error while connecting to WiFi network {ssid}: {error.Description}");
}
});
return true;
Just like #cole-xia-msft mentioned the link for the configuration work, the C# code would look like this.
var configuration = new NetworkExtension.NEHotspotConfiguration("SSID", "Password", false);
configuration.JoinOnce = true;
NetworkExtension.NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(configuration, (NSError error) =>
{
if (error != null) {
if (error?.LocalizedDescription == "already associated.")
Console.WriteLine("Connected");
else
Console.WriteLine("No Connected");
}
else
Console.WriteLine("Connected");
});
If your function enclosing the ApplyConfiguration call is asynchronous, you should consider using ApplyConfigurationAsync instead

after login unable to stay on current page

i am using $stateChangeStart instead of routechangestart , the problem i am facing is that after login whenever i refresh page i get redirected to home page,here is my code?
$rootScope.$on(‘$stateChangeStart’, function (event,next, toState, toParams,fromState, fromParams, options) {
if(next.name === “product.login” && $rootScope.authenticated) {
event.preventDefault();
} else if (next.name && next.data.requireLogin && !$rootScope.authenticated ) {
event.preventDefault();
$rootScope.$broadcast(“event:auth-loginRequired”, {});
}
else if (next.name && !AuthSharedService.isAuthorized(next.data.requiredRole)) {
event.preventDefault();
$rootScope.$broadcast(“event:auth-forbidden”, {});
}
}
);
$rootScope.$on(‘event:auth-loginConfirmed’, function (next,tostate,toparams, data,event)
{
console.log(‘login confirmed start for ‘ + tostate);
$rootScope.loadingAccount = false;
var nextLocation = ($rootScope.$state.current.name? $rootScope.$state.current.name : “frontProduct.productgrid”);
Session.create(tostate);
$rootScope.account = Session;
$rootScope.authenticated = true;
$state.go(nextLocation);
});
i just want to stay on current page.help me!
Hope you doing well
you have to also specify if user is not authenticated then where user redirect
if (!$rootScope.userloggedIn && !$rootScope.authenticate) {
$state.go("login");
event.preventDefault();
}
else{
$state.go("home");
}
look like this.
Hope this help you.
found answer,
$rootScope.$on('$stateChangeStart', function (event,next, toState, toParams,fromState, fromParams) {
if(next.name === "product.login" && $rootScope.authenticated) {
event.preventDefault();
} else if (next.name && next.data.requireLogin && !$rootScope.authenticated ) {
if(next.name!="product.login"&&next.name!=""){$window.localStorage.setItem('url',next.name);}
event.preventDefault();
$rootScope.$broadcast("event:auth-loginRequired", {});
}
else if (next.name && !AuthSharedService.isAuthorized(next.data.requiredRole)) {
event.preventDefault();
$rootScope.$broadcast("event:auth-forbidden", {});
}
}
);
$rootScope.$on('event:auth-loginConfirmed', function (next,tostate,toparams, data,event,$stateProvider) {
console.log('login confirmed start for ' + tostate);
$rootScope.loadingAccount = false;
$rootScope.$state.current.name : "frontProduct.productgrid");
Session.create(tostate);
$rootScope.account = Session;
$rootScope.authenticated = true;
$state.go($window.localStorage.getItem('url'));
$window.localStorage.remove('url');
});
i just want to know is this a correct way.

Ajax request to pages within a windows phone app

I am building a windows phone mobile app with phonegap. I need to get some content from a particular page within the application...This is what I have for now:
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
try {
req = new ActiveXObject('Msxml2.XMLHTTP');
} catch (err2) {
try {
req = new ActiveXObject('Microsoft.XMLHTTP');
} catch (err3) {
req = false;
}
}
}
return req;
}
var first_req = getXMLHTTPRequest();
var firsturl = '/books/Col.xml';
first_req.open('GET', firsturl, true);
first_req.onreadystatechange = createResponse;
first_req.send(null);
function createResponse()
{
if (first_req.readyState == 4) {
if(first_req.status == 200)
{
navigator.notification.alert(
'sucess',
doNot,
'success',
'Worked'
);
}
else {
navigator.notification.alert(
"request.status = "+first_req.status,
doNot,
'Error',
'Try Again'
);
}
it doesn't work, the else block runs and alerts request.status = 0
Any help would be really appreciated

Facebook check in and windows phone

I've got a script that essentially gives the user the ability to check in to a specific location when they click it. Upon clicking it, it checks them into the same location each time.
On desktop this works fine and I suspect it works on Android too. I have a WP and thus obviously I want to get it working on there. This feature is pretty much going to be used exclusively on mobile so getting it working cross-device is important.
Now, to the actual issue. Upon clicking the check in button on WP it loads a blank page and hangs there. Whilst this may be a signal that it perhaps has checked in, when I look it hasn't. So it's hanging there and doing nothing.
This is the URL it's hanging on: https://m.facebook.com/dialog/oauth?display=touch&domain=www.staffscuesociety.com&scope=publish_stream&api_key=API_KEY&app_id=APP_ID&locale=en_US&sdk=joey&access_token=ACCESS_TOKEN&client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D18%23cb%3Df35fef827217048%26origin%3Dhttp%253A%252F%252Fwww.staffscuesociety.com%252Ff166245837c3b6e%26domain%3Dwww.staffscuesociety.com%26relation%3Dopener%26frame%3Df398a7113310e64&origin=2&response_type=token%2Csigned_request
and this is the code:
var button;
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
window.fbAsyncInit = function() {
FB.init({
appId : '260445377421174',
channelUrl : '//www.staffscuesociety.com/checkin/channel.html'
});
button = document.getElementById('checkinWidget');
if (!button) return;
if (!getPost()) {
allowCheckin();
} else {
allowUndo();
}
};
function setPost(value) {
var d = new Date();
d.setDate(d.getTime() + (10 * 60 * 1000));
document.cookie = 'post=' + escape(value) + ';expires=' + d.toUTCString();
}
function getPost() {
return getCookie('post');
}
function getCookie(key) {
currentcookie = document.cookie;
if (currentcookie.length > 0) {
firstidx = currentcookie.indexOf(key + '=');
if (firstidx != -1) {
firstidx = firstidx + key.length + 1;
lastidx = currentcookie.indexOf(';', firstidx);
if (lastidx == -1) {
lastidx = currentcookie.length;
}
return unescape(currentcookie.substring(firstidx, lastidx));
}
}
return '';
}
function checkin() {
allowNothing();
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me/permissions', function (permissions) {
if (permissions.data.length > 0 && permissions.data[0].publish_stream) {
FB.api('/me/feed', 'post', { message: null, place: '117072761683514' }, function(post) {
if (!post || post.error) {
showError();
} else {
setPost(post.id);
allowUndo();
}
});
} else {
allowCheckin();
}
});
} else {
allowCheckin();
}
}, {scope : 'publish_stream'});
}
function undo() {
allowNothing();
FB.api('/' + getPost(), 'delete', function(response) {
setPost('');
allowCheckin();
});
}
function allowNothing() {
button.onclick = function() { };
button.className = 'pressed';
}
function allowCheckin() {
button.onclick = checkin;
button.className = '';
}
function allowUndo() {
button.onclick = undo;
button.className = 'pressed tick';
}
function showError() {
button.className = 'pressed error';
}
}

AJAX XMLHttpRequest state undefined

In the following piece of JavaScript code, i'm executing GetData.php using AJAX. However, when i remove the comments to see the request object's state property, it turns up as undefined, although the PHP script is getting executed properly and my page is changing as i want it to. But i still need the state property. Any clue on what's going on here ?
function refreshPage()
{
var curr = document.getElementById('list').value;
var opts = document.getElementById('list').options;
for(var i=0;i<opts.length;i++)
document.getElementById('list').remove(opts[i]);
var request = new XMLHttpRequest();
request.onreadystatechange=
function()
{
if(request.readyState == 4)
{
//alert(request.state);
//if(request.state == 200)
{
fillOptions();
var exists = checkOption(curr);
var opts = document.getElementById('list').options;
if(exists == true)
{
for(var i=0;i<opts.length;i++)
if(curr == opts[i])
{
opts[i].selected = true;
break;
}
}
else
{
opts[0].selected = true;
}
refreshData();
}
/*else
{
alert(request.responseText);
//document.close();
}*/
}
}
request.open("GET","GetData.php?Address=" + address + "&Port=" + port,true);
request.send();
}
Do you mean request.status not request.state?
Try changing it to the .status and it should work just fine :)

Resources