Is there a way to recognize weather the input to Bot is from microphone or is text input? - web-chat

In my BOT I want to log the times when speech input was provided to the BOT. Is there a way to recognize it in my BOT Framework solution.

When a user speaks to a bot in Web Chat, the generated activity sent to the bot will include a channelData.speech property. You can use this as a marker for determining, in the bot, if the activity came from spoken or text input. The speech property is not appended when the activity is generated from text input. This applies to both Cognitive Services speech (channelId: 'directline') and Direct Line Speech (channelId: 'directlinespeech').
Example activity
{
type: 'message',
id: '26WpGqt6CCz7M8uRN0ugo9-o|0000002',
timestamp: 2021-01-28T23:12:10.281Z,
serviceUrl: 'https://directline.botframework.com/',
channelId: 'directline',
from: { id: '<<REDACTED>>', name: '', role: 'user' },
conversation: { id: '26WpGqt6CCz7M8uRN0ugo9-o' },
recipient: { id: '<<REDACTED>>', name: '<<REDACTED>>' },
textFormat: 'plain',
locale: 'en-US',
text: 'Hello.',
entities: [ [Object] ],
channelData: {
speech: {
alternatives: [
{
confidence: 0.51567326,
transcript: 'Hello.'
}
]
},
clientActivityID: '1611875530186v9cv78togd',
clientTimestamp: '2021-01-28T23:12:10.186Z'
},
rawTimestamp: '2021-01-28T23:12:10.2819155Z',
callerId: 'urn:botframework:azure'
}
Hope of help!

Related

Razorpay redirect to particular payment method

I am working on Razorpay integration in my React Native app. It is successfully integrated in app.
Right now it opens screen with all payment methods including Card, Netbanking, Wallet and UPI. What I want to achieve is to redirect user to specific payment method. Suppose if user selects Netbanking then instead of opening page with all payment method options it should be redirect to netbanking page of razorpay.
I googled it but didn't get specific flow to integrate it. Please let me know how to achieve it.
What I tried till now is as below:
var options = {
description: 'Credits towards consultation',
image: 'https://i.imgur.com/3g7nmJC.png',
currency: 'INR',
key: 'KEY',
amount: '100',
name: 'FOOO',
method:"netbanking",
//bank:"HDFC",
prefill: {
email: 'test#gmail.com',
contact: '919191919991',
name: 'Razorpay Software'
},
theme: {color: '#F37254'}
}
RazorpayCheckout.open(options).then((data) => {
// handle success
console.log("razorpay success : " + JSON.stringify(data));
alert(`Success: ${data.razorpay_payment_id}`);
}).catch((error) => {
// handle failure
console.log("razorpay success : " + JSON.stringify(error));
alert(`Error: ${error.code} | ${error.description}`);
});
Here, method:"netbanking", doesn't work. It always open initial page with all payment methods. I am using react-native-razorpay library for implementation.
If you are listing the payment methods on your page, then you can prefill the method at Razorpay based on user selection as below,
Other checkout options;
'prefill': {
'email': 'test#gmail.com',
'contact': '919191919991',
'name': 'Razorpay Software',
'method': 'netbanking', //card|upi|wallet
},
'theme': {
'color': '#F37254',
'hide_topbar': 'true', //To hide the back button
}

ExtJS4, tree.Panel null using a json proxy

I am trying to use Ext.tree.Panel with an Ext.data.TreeStore and an Ext.data.Model. I think I am doing things right but when checking my tree I can see a beatiful 'null' and that is not normal. And I think it could be because of my json url.
Let me explain how I am proceeding.
Here is how I define my Model:
Ext.define('SelectedModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'text', type: 'string'},
{name: 'id', type: 'string'},
{name: 'leaf', type: 'bool'},
{name: 'children', type: 'auto'},
{name: 'singleClickExpand', type: 'bool'},
{name: 'status', type: 'int'},
{name: 'checked', type: 'boolean'},
{name: 'fullIceCode', type: 'string'},
{name: 'withMenu', type: 'bool'},
]
});
I read that fields 'leaf' and 'children' are present by default in all trees (with 20 others fields). So I am not sure I have to mention them. All these fields are precisely those presents in my json response (however they are not always all present in every item, like you will see in my example below). As I don't really understand how ExtJS works (this is my first week of practicing) I am wondering if I really need to write in my Model all the fields present in my json response, or just those which are present in every item of my tree.
Let see how I define my Store in my Tree:
store: Ext.create("Ext.data.TreeStore",{
model: 'SelectedModel',
proxy: {
type: 'ajax',
url: this.myaction,
reader: {
type: 'json',
}
}
})
At the end of the Tree constructor, if I write a console.log(this.myaction) I obtain exactly what I want which is 'stSearchAction.do?action=product_tree'.
This url is the one that set the json response to the servlet. It leads to this method:
private ActionForward getSpecialToolProductTree(
HttpServletRequest request, HttpServletResponse response) throws SystemException, ApplicativeException {
if (strJsonProduct == null)
{
strJsonProduct = getAndCreateSessionIfNeeded(request).getStrJsonProductSelector();
}
System.out.println(strJsonProduct);
setResponse(response, strJsonProduct) ;
return null ;
}
The System.out.println(strJsonProduct) you can see shows me precisely the json string I want:
[{text : 'CASE CONSTRUCTION', id : '5 -122001754' , leaf : false , children : [{text : 'Engines', ... ... ... ... ... ... ..., singleClickExpand : true , status : 1 , checked : false , fullIceCode : 'Y.A.01.001', withMenu : true }
] , singleClickExpand : true , status : 1 }] , singleClickExpand : true , status : 1 }] , singleClickExpand : true , status : 1 }]
I don't see for now where is the problem, but I admit that I can be pretty blind sometimes.
Now the Tree:
Ext.define('Application.TreePanel', {
extend: 'Ext.tree.Panel',
requires: ['Ext.data.TreeStore'],
myaction: 'Unknown Url',
myrender: 'Unknown Render',
xtype: 'check-tree',
rootVisible: false,
useArrows: true,
frame: true,
title: 'Unknown title',
width: 250,
height: 300,
constructor: function(myaction, mywidth, myheight, myrender, mytitle) {
if (myaction) {
this.myaction = myaction;
}
if (myrender) {
this.myrender = myrender;
}
if (mytitle) {
this.title = document.getElementById(mytitle).innerHTML;
}
if (mywidth) {
this.width = mywidth;
}
if (myheight) {
this.height = myheight;
}
console.log(this.height);
},
config:{
renderTo: this.myrender,
store: Ext.create("Ext.data.TreeStore",{
model: 'SelectedModel',
proxy: {
type: 'ajax',
url: this.myaction,
reader: {
type: 'json',
}
}
})
}
});
When I check the different attributes set in my constructor with some console.log, I got exactly what I want...
All the extJs code I showed you is in a same file, tree421.js (because using ExtJS 4.2.1).
What I think is there is a problem with my store, I am not doing the right thing, maybe this is not the way of using the url config for a proxy... but I can't find the good way.
I obtain some strange results.
When executing these lines at the end of my tree421.js
var tree = Ext.create("Application.TreePanel", 'stSearchAction.do?action=product_tree', 300, 270, 'tree-div', 'lbl_st_tree_selection');
console.log(tree);
console.log(tree.getSelectionModel());
console.log(tree.getRenderTo());
console.log(tree.getRootNode());
I can read
j {myaction: "stSearchAction.do?action=product_tree", myrender: "tree-div", title: "Product selection", width: 300, height: 270…} tree421.js:117
A {events: Object, views: Array[0], modes: Object, selectionMode: "SINGLE", selected: A…} tree421.js:118
undefined tree421.js:119
null tree421.js:120
The second log is just a test to see what would be written but I don't really care. We can see that the tree.getRenderTo() is undefined, but I put it in config block so getters & setters should be generated, and a console.log(this.myrender) in the constructor wrote something good, so I don't understand what is going on.
And last but not least my tree.getRootNode() is null...
It would be appreciated if someone with a better ExtJS understanding could advice me. I feel like there is something wrong with my way of using json url but I don't understand why. Or maybe it is something else...
Thank you for your time.
Poney
Ok so I worked on others trees from less important projects to get familiar with this concept and with javascript and EXTJS.
So now I come back on this one and I can say that it worked fine in fact but I was not correctly getting the informations after the tree construction.
The reason is that I am working on the migration of some projects from extjs-3.2.1 to extjs-4.2.1 and the whole tree system has changed. The operations node.attributes.something I used to make to get informations from a node don't work anymore and I have to pass through node.data.somethingor node.raw.something. That's all.
I just had to precise a reader and a root to my tree too.
Anyway here is the essential part of the tree:
Ext.define('SelectedModel', {
extend: 'Ext.data.Model',
fields: [
{name: 'text', type: 'string'},
{name: 'id', type: 'string'},
{name: 'leaf', type: 'bool'}
]
});
var tree = Ext.create('Ext.tree.TreePanel',{
renderTo:myrender,
title: document.getElementById(mytitle).innerHTML,
height: myheight,
width: mywidth,
useArrows:true,
autoScroll:true,
animate:true,
ddConfig:{
enableDrag:false,
enableDrop:false
},
containerScroll: true,
rootVisible: false,
frame: true,
store: Ext.create('Ext.data.TreeStore',{
model: 'SelectedModel',
proxy:{
type: 'ajax',
url: myaction,
reader: {
type: 'json'
},
root: {
type: 'async'
}
},
autoLoad: false
});
So there was not any problem, I just had to practice a little javascript and extjs4 and get used to javascript debugging. :)
Now I can appreciate it a little more.
Thank you

CKeditor removes ul list

I am copying html code which has "ul","li" tags, clicking "Source" and pasting it to CKEditor. However, when i go to design, it replaces those tags with "". Is this a bug or did i configure something wrong? Below is the config.js file content.
CKEDITOR.editorConfig = function (config) {
// Define changes to default configuration here.
// For the complete reference:
// http://docs.ckeditor.com/#!/api/CKEDITOR.config
// The toolbar groups arrangement, optimized for two toolbar rows.
config.toolbarGroups = [
{ name: 'clipboard', groups: ['clipboard', 'undo'] },
{ name: 'editing', groups: ['find', 'selection', 'spellchecker'] },
{ name: 'links' },
{ name: 'insert' },
{ name: 'forms' },
{ name: 'tools' },
{ name: 'document', groups: ['mode', 'document', 'doctools'] },
{ name: 'others' },
'/',
{ name: 'basicstyles', groups: ['basicstyles', 'cleanup'] },
{ name: 'paragraph' },
{ name: 'styles' },
{ name: 'colors' },
{ name: 'about' }
];
// Remove some buttons, provided by the standard plugins, which we don't
// need to have in the Standard(s) toolbar.
config.removeButtons = 'Underline,Subscript,Superscript';
config.filebrowserImageBrowseUrl = '/Admin/BrowseImage';
config.filebrowserImageUploadUrl = '/Admin/UploadImage';
I'm assuming that you're using latest CKEditor (4.1) which comes with Advanced Content Filter. It means that lists will be cleared out of your content unless you have either list plugin loaded with all the features (buttons and commands) or explicitly defined config.allowedContent to accept lists.
It also means that if you remove list buttons, editor assumes that you don't want list in your content and they're simply gone. Your config.toolbarGroups has no list entry and this the root of your problem. You can check whether tag is allowed by typing this in your console:
CKEDITOR.instances.yourEditorInstance.filter.check( 'li' );
>> false
When you add something like this to your config, lists will be back in the editor with UI:
{ name: 'paragraph', groups: [ 'list' ] }
If you really want to preserve your toolbar but allow lists, you can specify:
config.extraAllowedContent = 'ul ol li'.
Also read more about allowedContent rules to know more and use things intentionally.

JSON schema for data description vs data validation vs input validation

In what I can find about using JSON schema, there seems to be a confusing conflation of (or at least a lack of distinction among) the tasks of describing valid data, validating stored data, and validating input data.
A typical example looks like:
var schema = {
type: 'object',
properties: {
id: { type: 'integer', required: true },
name: { type: 'string', required: true },
description: { type: 'string', required: false }
}
};
This works well for describing what valid data in a data store should look like, and therefore for validating it (the latter isn't terribly useful—if it's in a store it should be valid already):
var storedData = {
id: 123,
name: 'orange',
description: 'delicious'
};
It doesn't work that well for validating input. id is most likely left for the application to generate and not for the user to provide as part of the input. The following input fails validation because it lacks the id which the schema declares to be required:
var inputData = {
name: 'orange',
description: 'delicious'
};
Fine, one might say, the schema isn't meant to validate direct input, validation should only occur after the application added an id and the data is what is meant to be stored.
If the schema isn't meant to validate direct input, however, what is 1) the point of JavaScript validators running in the browser, presumably being fed direct input and 2) the point of the obviously input-oriented readonly schema feature in the spec?
Ground gets shakier when thinking of properties that can be set once but not updated (like a username), as well as different access levels (e.g. the admin and the owner of the orange should be able to change the description, while for other users it should stay readonly).
What is the best (or at least working) practice to deal with this? A different schema for each use case, like below?
var baseSchema = {
type: 'object',
properties: {
id: { type: 'integer', required: true },
name: { type: 'string', required: true },
description: { type: 'string', required: false }
}
};
var ownerUpdateSchema = {
type: 'object',
properties: {
id: { type: 'integer', required: false, readonly: true },
name: { type: 'string', required: true },
description: { type: 'string', required: false }
}
};
var userUpdateSchema = {
type: 'object',
properties: {
id: { type: 'integer', required: false, readonly: true },
name: { type: 'string', required: false, readonly: true },
description: { type: 'string', required: false, readonly: true }
}
};
Or something else?
Side-note: "required" is now an array in the parent element in v4, and "readOnly" is capitalised differently - I'll be using that form for my examples
I agree that validating the stored data is pretty rare. And if you're just describing the data, then you don't need to specify that "id" is required.
Another thing to say is that these schemas should all have URIs at which they can be referenced (e.g. /schemas/baseSchema). At that point, you can extend the schemas to make "id" required in some of them:
var ownerInputSchema = {
type: 'object',
properties: {
id: {type: 'integer', readOnly: true},
name: {type: 'string'},
description: {type: 'string'}
},
required: ['name']
};
var userInputSchema = {
allOf: [{"$ref": "/schemas/inputSchema"}],
properties: {
name: {readOnly: true}
}
};
var storedSchema = {
allOf: [{"$ref": "/schemas/inputSchema"}],
required: ["id"]
}
Although, as I said above, I'm not sure storedSchema should be necessary. What you end up with is one "owner" schema that describes the data format (as served, and as editable by the data owner), and you have a secondary schema that extends that to declare readOnly on an additional property.
Well, I think the purpose of Json-Schema is more clearly defined in v4. The goal is assist you in a data structure validation (whether it is going to be stored, it has been sent to you across the wire, or you are creating in an interactive fashion).
readOnly is not a Json-Schema validation property because it has not validation constraints. In Json-Schema v4 readOnly is part of the hyper-schema definition. It can be used to express that you can not change this property in a POST request.
Json-schema does not define how you should implement the interaction with the user, if you allow for transitory "bad" data, or if any error has to be corrected before you can add more data to the system. This is up to you.

Nested JSON objects in Sencha Touch store using CakePHP backend API

I am using Sencha Touch 1.1 to build a bar locator. I am using CakePHP as my backend API and I want to be able to use the data as Cake outputs it.
Viewing the JSON data below you will see that the Pub data is returned in the 'Pub' array and the Suburb in a similar way. So accessing the data would be done as follows:
Pub.id, Pub.name, Pub.address_1
Does anyone know how I can use this format in my Sencha model and store?
I have my model and store setup as follows:
Ext.regModel('Pub', {
fields: ['id', 'name', 'address_1', 'address_2', 'marker', 'lat', 'lng', 'suburb']
});
Ext.regStore('NearbyStore', {
model: 'Pub',
sorters: 'suburb',
getGroupString: function(record) {
return record.get('suburb');
},
proxy: {
type: 'scripttag',
url: 'http://exampleurl/bars/nearby.json?lat=-55.8874&lng=-11.177',
reader: {
type: 'json',
root: 'results'
}
},
autoLoad: true
});
Below is the JSON data that is returned from my store proxy.
stcCallback1001({"results":[{"Pub":{"id":"125","name":"Brownsville Bowling & Recreation Club","address_1":"31a malouffst","address_2":"-","marker":"default_marker.png","lat":"-33.887402","lng":"151.177002"},"Suburb":{"name":"Knoxville"},"0":{"distance":"0.0002511751890598611"}},{"Pub":{"id":"1721","name":"Hampshire Hotel","address_1":"91 parramatta rd","address_2":"-","marker":"default_marker.png","lat":"-33.886799","lng":"151.177002"},"Suburb":{"name":"Brownsville"},"0":{"distance":"0.06684402352323478"}}]});
you should see
http://docs.sencha.com/touch/1-1/#!/api/Ext.data.Field-cfg-mapping
similar question on stackoverflow :
Accessing nested objects in JSON feed - Sencha Touch
So you should map your model like this :
Ext.regModel('Pub', {
fields: [
{
name: 'id',
type: 'string',
mapping: 'Pub.id'
},
{
name: 'name'
type: 'string',
mapping: 'Pub.name'
},
{
name: 'address_1',
type: 'string',
mapping: 'Pub.address_1'
},
{
name: 'AND SO ON.......'
}
});
Well, I've just started on sencha touch. So I hope im helping.. :)
you will not only have to make these, but also map filtering, remote sorting, success properties, validation errors, and so on. If you are planning a bigger project I would recommend you to switch to Sencha Touch 2 and use Bancha.
Then you will not have to do any of those things. And as a nice bonus you can simply expose your CakePHP models and don't have to write them manually again for Sencha Touch.