Send delete key in Chrome Input.dispatchKeyEvent API? - google-chrome-extension

I just want to send a delete key in the Chrome extensions API, but it doesn't work but doesn't do anything.
I tried:
chrome.debugger.sendCommand(target, "Input.dispatchKeyEvent", { type: 'rawKeyDown', keyIdentifier: 'U+2421' })
And:
chrome.debugger.sendCommand(target, "Input.dispatchKeyEvent", { type: 'rawKeyDown', keyIdentifier: 'Delete' })
But neither worked.
How can I type a "delete" in the API?

Related

How to send hero cards to the fb messenger using microsoft bot framework while using waterfall dialogs (Node js)

I am trying to create a messenger bot using Microsoft bot framework
I am using a waterfall dialog to create the flow of the structure.
In this, I have multiple steps were in a particular step I need to send a carousel of four hero cards with buttons for each.
I have used the answer by steven,
Handling HeroCards responses In Microsoft Bot Framework v4 for NodeJS
I work fine while testing in bot emulator and webchat
But produces an error while testing in messenger bot
can anyone help me to rectify this error, Thanks in advance
async locationStep(step) {
// WaterfallStep always finishes with the end of the Waterfall or with another dialog; here it is a Prompt Dialog.
// Running a prompt here means the next WaterfallStep will be run when the user's response is received.
await this.sendIntroCard(step)
await step.context.sendActivity("How often do you use surface on the move?")
let acard =CardFactory.heroCard(
" ",
[`https://scontent.fmaa1-4.fna.fbcdn.net/v/t1.0-9/89121134_2372258766207358_5255590702309441536_n.jpg?_nc_cat=109&_nc_sid=8024bb&_nc_ohc=1cHak5WO_yoAX-VdtfO&_nc_ht=scontent.fmaa1-4.fna&oh=fd002544bc74bf53ae0185f4c192efe6&oe=5E82E09B`],
[{ type: ActionTypes.PostBack,
title: 'Never',
value: 'Never'}]
);
let bcard =CardFactory.heroCard(
" ",
['https://i.imgur.com/m2DWB7m.jpg'],
[{ type: ActionTypes.PostBack,
title: 'Once in a while',
value: 'Once in a while'}]
);
let ccard =CardFactory.heroCard(
" ",
['https://i.imgur.com/Kwn0FBn.jpg'],
[{ type: ActionTypes.PostBack,
title: 'A few days a week',
value: 'A few days a week'}]
);
let dcard =CardFactory.heroCard(
" ",
['https://i.imgur.com/mAlW0Bv.jpg'],
[{ type: ActionTypes.PostBack,
title: 'Every day',
value: 'Every day'}]
);
await step.context.sendActivity( {attachments:[acard,bcard,ccard,dcard],attachmentLayout: AttachmentLayoutTypes.Carousel
});
return await { status: DialogTurnStatus.waiting };
}
Your issue is caused by the space you have included as the title of your hero cards: " ". Fixing your problem is simple. You can using an actually empty string without the space ("") or even omitting the title altogether.
EDIT: As you've seen, the Bot Framework will add "Options" as the card's title if you haven't provided one because it uses Facebook Messenger's generic template which requires a title. There is nothing the Bot Framework can do and there's nothing you can do to bypass Facebook's API restrictions. However, if you really want to send a card with an image and buttons then you can use a media template. This will be inconvenient because you'll need to upload the image attachment beforehand so you can get an attachment ID using this API: https://developers.facebook.com/docs/messenger-platform/reference/attachment-upload-api
Rather than having your bot upload the images every time it needs to use them, you should be able upload each image once on your own and then give the ID's to your bot. Once you've uploaded your attachments, you can send a media template directly using the Send API or using the Bot Framework activity's channel data according to these instructions: https://blog.botframework.com/2017/03/28/custom-channel-data/
await step.context.sendActivity( {
"channelData": {
"attachment": {
"type": "template",
"payload": {
"template_type": "media",
"elements": [
{
"media_type": "image",
"attachment_id": "<YOUR_ATTACHMENT_ID>",
"buttons": [
{
"type": "postback",
"payload": "Never",
"title": "Never"
}
]
},
// More media templates ...
]
}
}
}
} );
Since this may be more complicated than you'd like, you might consider an alternative design like Messenger's quick replies.

Telegram bot - Remove keyboard - Nodejs

I'm facing a very strange issue that is probably linked to cache.
So here it is .
I have developped a bot in nodejs for telegram.
This bot HAD in the past a custom keyboard that was not a "inline_keyboard"
I decided to change that behaviour and have implemented inline_keyboard.
current code is something like that :
var options = {
parse_mode: "Markdown",
disable_web_page_preview: true,
reply_markup: JSON.stringify({
inline_keyboard: [
[{
text: '🇫🇰 English',
callback_data: "SET ENGLISH"
},{
text: '🇫🇷 Français',
callback_data: "SET FRENCH"
}]
]
})
};
bot.sendMessage(msg.chat.id, "Please choose your language",options);
Inline_keyboard is working fine but my old code (that has been deleted) is still appearing to my users and is very anoying.
Here it is; it keeps on appearing when my users log into my chat.
I have been the following ressources :
https://core.telegram.org/bots/api#replykeyboardremove
How do you remove reply keyboard without sending a message in Telegram?
https://core.telegram.org/bots/api#editmessagereplymarkup
But i don't see how to implement it so I can remove this annoying chat for my users.
Any suggestions ?
Thx for your support
there may be different solutions to do so, my suggestion:
you can use the very first answer of each user to remove keyboard, first use editMessageText to remove keyboard and then send him the appropriate answer.(note that persist chatIDs that you have removed their keyboard, so you will do this for each user just once)
bot.on('callback_query', function onCallbackQuery(callbackQuery) {
if(!didWeRemoveHisKeyboard(callbackQuery.from.id))
removeHisKeyboard(callbackQuery)
//then handle the user response
})
removeHisKeyboard = function(callbackQuery){
bot.editMessageText(callbackQuery.message.text,
{message_id:callbackQuery.message.message_id , chat_id:callbackQuery.from.id,
reply_markup: {
remove_keyboard: true
}}).catch((err) => {
//some error handling
}).then(function(res){
if(res)
addThisChatToHandledList(callbackQuery.from.id)
})
}
note that you may need some modification on this code based on the node_module you're using.

I'm trying to make sense of session, but cannot get any data out of it

Currently using LUIS in a bot that connects to Slack. Right now I'm using interactive messages and trying to respond to user input correctly. When I click an item from the drop down LUIS receives it as a message. I can get the text with session.message.text, however I need to get the callback_id of the attachment as well as the channel it was sent from.
I've used console.log(session) to get an idea of what session looks like. From there I've seen that session.message.sourceEvent contains the data I need, however I can't use indexOf() or contains() to actual extrapolate the data. I've also tried session.message.sourceEvent.Payload but end up getting "[object [Object]]". I've tried searching for documentation on session formatting but to no avail.
Below is a snippet of what is returned when I run console.log(session.message.sourceEvent).
{ Payload:
action_ts: '1513199773.200354',
is_app_unfurl: false,
subtype: 'bot_message',
team: { id: 'T03QR2PHH', domain: 'americanairlines' },
user: { id: 'U6DT58F2T', name: 'john.cerreta' },
message_ts: '1513199760.000073',
attachment_id: '1',
ts: '1513199760.000073' },
actions: [ [Object] ],
callback_id: 'map_selection1',
original_message:
username: 'Rallybot',
response_url: 'https://hooks.slack.com/actions/T03QR2PHH/287444348935/Y6Yye3ijlC6xfmn8qjMK4ttB',
type: 'message',
{ type: 'interactive_message',
channel: { id: 'G6NN0DT88', name: 'privategroup' },
token: 'removed for security',
{ text: 'Please choose the Rally and Slack team you would like to map below.',
bot_id: 'B7WDX03UM',
attachments: [Array],
trigger_id: '285857445393.3841091595.085028141d2b8190b38f1bf0ca47dd88' },
ApiToken: 'removed for security' }
session.message.sourceEvent is a javascript Object, however indexOf or contains are functions of String or Array types.
Any info you required in the object, you should direct use the code <object>.<key> to invoke that value. You can try session.message.sourceEvent.Payload.action_ts for example.
Also, you can use Object.keys(session.message.sourceEvent) to get all the keys in this object.

Ember.js data records shows content: null in relationships inspector

I have the following code in my 'user.js' model in ember-data:
export default DS.Model.extend({
organization: DS.belongsTo('organization'),
//other stuff
});
The CRUD for the website is working as expected, and in MongoDB I can see the following for the organization field of User:
"organization" : ObjectId("571974742ce868d575b79d6a"),
BUT, and I'm not sure if this is an error in my code or me not understanding how Ember-data works, I cannot access that ID from a model hook like so:
model(){
return this.store.findRecord("user", this.get("session.currentUser.id"))
.then(user => this.store.findRecord("location", {organization: user.organization}));
}
And if I go to the Ember inspector to observe the belongsTo attribute of the User object, I see:
organization: <(subclass of Ember.ObjectProxy):ember956>
But clicking through I see content: null
What am I doing wrong? Could it be a server-side error?
Edit including JSON response from server for the above findRecord("user") call:
{
"links":{
"self":"/users/5719749a2ce868d575b79d6b"
},
"included":[
{
"type":"organizations",
"id":"571974742ce868d575b79d6a",
"links":{
"self":"/organizations/571974742ce868d575b79d6a"
},
"attributes":{
"creation-date":"2016-04-22T00:46:44.779Z"
}
}
],
"jsonapi":{
"version":"1.0"
},
"data":{
"type":"users",
"id":"5719749a2ce868d575b79d6b",
"links":{
"self":"/users/5719749a2ce868d575b79d6b"
},
"attributes":{
"email":"danthwa#gmail.com",
"first-name":"Daniel",
"last-name":"Thompson",
"registration-date":"2016-04-22T00:47:22.534Z"
},
"relationships":{
"organization":{
"type":"organizations",
"id":"571974742ce868d575b79d6a"
}
}
}
}
Confirmed. As stated by Kingpin2k,
the relationships isn't being built up correctly, I think the type and id inside of organization need to be within a data object.
This applies to Ember sites expecting a JSON API spec payload, meaning they have been configured to use JSONAPISerializer for incoming payloads.

possible spotify portrait metadata caching bug

Code to replicateIn my app I have the following code.
var seed = "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP";
sp.core.getMetadata(seed, {
onSuccess: function (metadata) {
console.log(metadata);
},
onFailure: function () {}
});
Steps to view the behaviour
If spotify is already open close it and then reopen it, after opening spotify run the app and view the console Which displays as
Object
name: "Whitesnake"
portrait: ""
type: "artist"
uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"
__proto__: Object
Then click on the radio app and create a station based on the the band Whitesnake.
Rerun the original app and view the console output which will display.
Object
name: "Whitesnake"
portrait: "spotify:image:3c4aa30d845dd456d750cf16bef8e2cadb2af342"
type: "artist"
uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"
__proto__: Object
Quit spotify and rerun the original application and view the console which will display
Object
name: "Whitesnake"
portrait: ""
type: "artist"
uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"
__proto__: Object
Question
Why is the radio app able to access a portrait uri that is then accessible from my app after using the radio app? Is there some sort of initialization, that needs to be done first or is this a bug?
Some information on an artist (and album, etc) isn't available until you do a "browse" on that URI - until then, Spotify only downloads basic information on an item to keep performance up.
What you're seeing is the Radio doing a browse, which causes the Spotify client to fill in the missing information.
An update to Spotify is coming soon that will improve this behaviour.
If I understood you correctly, you've noticed that after you get the result with a portrait URI from the radio, you get that object data populated when using it in your app?
On another note; you should be using the Artist class instead of sp.core.
var sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
models.Artist.fromURI("spotify:artist:3UbyYnvNIT5DFXU4WgiGpP", function(album) {
console.log(album);
});
This should give you the correct output with a portrait uri string.
Artist
data: Object
name: "Whitesnake"
portrait: "spotify:image:3c4aa30d845dd456d750cf16bef8e2cadb2af342"
type: "artist"
uri: "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP"
As iKenndac mentioned, try doing a 'browse':
var seed = "spotify:artist:3UbyYnvNIT5DFXU4WgiGpP";
sp.core.browseUri(seed, {
onSuccess: function (metadata) {
console.log(metadata);
},
onFailure: function () {}
});
Examples here: https://github.com/ptrwtts/kitchensink

Resources