Combining reply and postback buttons - smooch

How do I combine action buttons of multiple types (reply and postback) within one message? Example:
{
"type":"text",
"text":"The more you know, am I right? Would you like to learn...",
"actions":[
{
"type":"postback",
"text":"From a human",
"payload":"Edu - human"
},
{
"type":"reply",
"text":"From content",
"payload":"Edu - content"
},
{
"type":"reply",
"text":"From your peers",
"payload":"Edu - community"
},
{
"type":"reply",
"text":"Something else",
"payload":"Something else"
},
{
"type":"reply",
"text":"just to test",
"payload":"just to test"
}
],
"role":"appMaker",
"name":"Flowdev"
}
The example above is just not shown in Smooch chat. If I change first action type to reply or change other three to postback the message will be shown.

postback actions can be combined with other persistent button types (link/buy/etc.)
reply actions cannot be combined with persistent buttons.

Related

Huginn: Extract text from html tag using Website Agent css selector

I'm trying to understand how the web-scraping is done in Huginn but I cannot find proper documentation on the options available.
I'd like to extract the price of the Gold oz. from this website for example:
https://www.xe.com/currencyconverter/convert/?Amount=1&From=XAU&To=USD
For which I use a Huginn Website Agent with this code:
{
"expected_update_period_in_days": "2",
"url": "https://www.xe.com/currencyconverter/convert/?Amount=1&From=XAU&To=USD",
"type": "html",
"mode": "on_change",
"extract": {
"price": {
"css": ".converterresult-toAmount",
"value": "."
}
}
}
I got the css selector using SelectorGadget and I've tried multiple values like: ./node(), string(.), normalize-space(.), . , //text() and others, but I cannot find the way to extract the content of the span html tag that contains that value. Here the code of that section of the web:
<span class="converterresult-toAmount">1,730.35</span>
And what I want to extract is: 1,730.35
i got it working on another site.
i used "xpath" for it.
I used a different site because it wouldn't work on the one you posted.
But i hope this still helps someone.
{
"expected_update_period_in_days": "2",
"url": "https://walletinvestor.com/converter/xau/usd/1",
"type": "html",
"mode": "on_change",
"extract": {
"gold_in_dollar_price": {
"xpath": "/html/body/div[4]/div/div[3]/div[1]/h2/strong/span",
"value": "string(.)"
}
}
}
Here is how you get the XPath of any Element/Object on a website:
(i used Yandex Browser based on chrome for this)
Open the Developer Tools in the Browser (or right click and select "Inspect element code")
Select / Click with the Inspector on your Element/Object
You should now see something like:
<span class="converterresult-toAmount">1,730.35</span>
Right click on this and click: "copy" > "Copy XPath"
Im using Huginn since 2 Days so anyone feel free to tell me any faster way if there is any :)

hangouts api cards trimming text

Im trying to send large descriptions inside a card using the google hangout api; but unfortunately the text is being trimmed when its too long.
Below is a sample of the card I send:
"cards": [{
"sections": [{
"widgets": [{
"keyValue": {
"topLabel": "Label",
"content": "Long Description goes here..."
}
}
]
}
]
}
]
When I look at the html received by the bot the content is in a dive with white-space: nowrap;...
I tried placing the content in a div and giving it white-space: wrap; as such
"content": "<div style='white-space: wrap;'>Long Description...</div>", but the bot just removes that div when it sends the card.
I also noticed that on pc browser the text was trimmed at 43 characters, so I used regex to add \n at every 43 character using .replace(/.{42}/g, '$&\n'), which kind of works but on mobile the card seems to trim messages even more...
Anyway I could simply remove that annoying white-space style??
EDIT
I know about this post, but it tries to increase width of the card (which technically would work for me), and there were no solutions...
It is possible to do it and very simple:
You only have to add contentMultiline: true to your KeyValue property.
"cards": [{
"sections": [{
"widgets": [{
"keyValue": {
"topLabel": "Label",
"content": "The working day is thus not a constant, but a variable quantity. One of its parts, certainly, is determined by the working-time required for the reproduction of the labour-power of the labourer himself. But its total amount varies with the duration of the surplus labour. The working day is, therefore, determinable, but is, per se, indeterminate.",
"contentMultiline": true,
}
},
]
}
]
}
]
Here you'll find the documentation of KeyValue fields:
https://developers.google.com/hangouts/chat/reference/rest/v1/cards#keyvalue

Ionic Navigate from picture

I have a section in my apps that loads data from a JSON file and displays pictures in a grid.
Example of JSON data:
"categories": [
{
"title": "Test",
"image": "./assets/images/listing/200x200basquet.png",
"page": "TestPage"
},
Now I have a function when you click on one of the images it navigates you to 1 page, instead of different pages per image.
goToFeed(category: any) {
console.log("Clicked goToFeed", category);
this.nav.push(FeedPage, {
category: category
});
}
Does anybody have an idea on how can I re-write that function to specific navigate to the page that the image correlates?
Thanks

Can you rename the "Option" label ? ( Chrome-Extension )

I tried this : https://developer.chrome.com/extensions/options.html and made an option page.
So a selection has been added under my extension icon with the name of Option.
My question is that is there a way to rename Option and change it something like Setting or some words in other languages ?
The "Options" label at chrome://extensions is automatically adapted to the user's language. Extensions cannot change the value of this label.
The value of the "Options" option at the dropdown menu at the extension's button cannot be customized either, but you can create a new context menu item under the button as of Chrome 38. E.g.
chrome.contextMenus.create({
id: 'show-settings', // or any other name
title: 'Settings',
contexts: ['page_action', 'browser_action']
});
chrome.contextMenus.onClicked.addListener(function(info, tab) {
if (info.menuItemId == 'show-settings') {
chrome.tabs.create({
url: chrome.runtime.getURL('settings.html')
});
}
});
I suggest to just stick to "Options" though, because users do already know what the option does. Consistency in UI/UX is important, imagine how you productive you'd be if every application had a different way of (e.g.) closing/quiting the application.
manifest.json to test the previous script:
{
"name": "Contextmenu on browserAction button",
"version": "1",
"manifest_version": 2,
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_title": "Right-click to see a context menu"
},
"permissions": [
"contextMenus"
]
}
Easier way to trigger events.
chrome.contextMenus.create({
title: 'GitHub',
contexts: ['page_action'],
onclick: () => console.log('GitHub'),
});

Custom Chrome URL suggestions

One of the neat things about Chrome is that, if you type a word on the address bar, it suggests what relevant URLs might be. For example if I type "New York", it suggests nytimes.com
Can an extension be developed that provides customized suggestions? For instance, if I have an internal company website, say foo which hosts documents with numeric IDs - say http://domain.com/123 or http://domain.com/234. When someone types "123" on the browser address bar, I want http://domain.com/123 to show as a suggestion (even if it has never been accessed before).
Is something like this possible? If so, I would love some pointers (I've never developed a Chrome extension, but if possible, I can look things up and get this implemented).
Thanks!
Raj
Yes, it is possible through Omnibox, https://developer.chrome.com/extensions/omnibox.html
I have written a sample implementation here :
Manifest File:
{
"name": "Omnibox Demo",
"description" : "This is used for demonstrating Omnibox",
"version": "1",
"background": {
"scripts": ["background.js"]
},
"omnibox": {
"keyword" : "demo"
},
"manifest_version": 2
}
JS File:
chrome.omnibox.setDefaultSuggestion({"description":"Search %s in Dev Source Code"});
chrome.omnibox.onInputStarted.addListener(function() {
console.log("Input Started");
});
chrome.omnibox.onInputCancelled.addListener(function() {
console.log("Input Cancelled");
});
chrome.omnibox.onInputEntered.addListener(function (text) {
console.log("Input Entered is " + text);
});
chrome.omnibox.onInputChanged.addListener(
function(text, suggest) {
console.log('inputChanged: ' + text);
suggest([
{content: text + " one", description: "the first one"},
{content: text + " number two", description: "the second entry"}
]);
});