Getting Unsuccessful webhook call: Failed to translate JSON to ExecuteHttpResponse for table in #assistant/conversation - google-assistant-sdk

I am trying to show a table in my cloud function using the new #assistant/conversation with the array of data but when i test the action i am getting the error as below
Unsuccessful webhook call: Failed to translate JSON to ExecuteHttpResponse
But when i check the logs i am getting the row values like below
{
"responseJson": {
"session": {
"id": "ABwppHE5M8EGlWf3YmpUUGPQ5xxHh-cb2QYyF_YUarZbF_jXq-Ad2iKDtyI8XAyvWPp4hHnQockBWMZuQA",
"params": {},
"languageCode": ""
},
"prompt": {
"override": false,
"content": {
"table": {
"button": {},
"columns": [
"Date",
"Time",
"Place"
],
"image": {},
"rows": [
"20-10-2020",
"11:20",
"Test"
],
"subtitle": "",
"title": ""
}
}
}
}
}
Here is the implementation of my adding table in the conv
const tempDatas = ['20-10-2020', '11:20', 'Test'];
conv.add(
new Table({
dividers: true,
columns: ['Date', 'Time', 'Place'],
rows: tempDatas
})
);
I have used the same logic in google-actions plugin there it works fine.I have imported the Table like below
const { conversation, Table } = require('#assistant/conversation');

Fixed the issue. The structure provided by the new actions builder is little different with the old one
New Structure:
conv.add(new Table({
'title': 'Table Title',
'subtitle': 'Table Subtitle',
'image': ASSISTANT_LOGO_IMAGE,
'columns': [{
'header': 'Column A',
}, {
'header': 'Column B',
}, {
'header': 'Column C',
}],
'rows': [{
'cells': [{
'text': 'A1',
}, {
'text': 'B1',
}, {
'text': 'C1',
}],
}, {
'cells': [{
'text': 'A2',
}, {
'text': 'B2',
}, {
'text': 'C2',
}],
}, {
'cells': [{
'text': 'A3',
}, {
'text': 'B3',
}, {
'text': 'C3',
}],
}],
}));
You can simplify it like below that is the solution for my above issue
const tableRows = [];
tablesRows.push({ 'cells': [{ 'text': moment(data.date).format('DD-MM-YYYY') }, { 'text': data.time }, { 'text': data.place }] });
conv.add(new Table({
'columns': [{
'header': 'Date',
}, {
'header': 'Time',
}, {
'header': 'Place',
}],
'rows': tablesRows,
}));
For more info visit conversation components

Related

Click on images in adaptive card is not triggering action on IOS devices

Click on images in the adaptive card is not triggering action on IOS devices despite its opening the image viewer.
click is working expected on the web app, desktop app, and Android devices
but failing on ios devices.
adaptive card with the clickable image.
after clicking its opening like this.
Card Json:
{
'contentType': 'application/vnd.microsoft.card.adaptive',
'content': {
'type': 'AdaptiveCard',
'version': '1.2',
'body': [
{
'type': 'TextBlock',
'size': 'medium',
'weight': 'Bolder',
'text': 'Here is the list of top analysis created for you: '
},
{
'type': 'ColumnSet',
'columns': [
{
'type': 'Column',
'spacing': 'medium',
'items': [
{
'type': 'Container',
'items': [
{
'type': 'Image',
'url': {image_url},
'horizontalAlignment': 'Center',
'width': '96px',
'height': '96px'
}
],
'selectAction': {
'type': 'Action.Submit',
'tooltip': 'Submit action',
'data': {
'bot_id': 113
}
}
},
{
'type': 'ColumnSet',
'verticalAlignment': 'Center',
'columns': [
{
'type': 'Column',
'items': [
{
'type': 'TextBlock',
'text': 'Beagle Recruit',
'horizontalAlignment': 'Center',
'weight': 'bolder',
'wrap': True,
'maxLines': 2
}
]
}
]
}
],
'width': 'stretch',
'horizontalAlignment': 'Center'
}
],
'horizontalAlignment': 'Center'
},
{
'type': 'ColumnSet',
'columns': [
],
'horizontalAlignment': 'Center'
},
{
'type': 'TextBlock',
'text': 'Select more analysis from the drop-down: ',
'spacing': 'extralarge',
'weight': 'Bolder',
'wrap': True
},
{
'type': 'Input.ChoiceSet',
'id': 'botid_d',
'spacing': 'large',
'isMultiSelect': False,
'value': 0,
'placeholder': 'List of analysis',
'choices': [
{
'title': 'List of analysis',
'value': 0
},
{
'title': 'Beagle Recruit',
'value': 113
}
]
},
{
'type': 'ActionSet',
'style': 'default',
'spacing': 'large',
'actions': [
{
'type': 'Action.Submit',
'color': 'default',
'title': 'Open'
}
]
}
],
'msteams': {
'width': 'Full'
}
}
}
We tried with the below json and it worked for us both in teams desktop/web and mobile clients(iOS). On click of images is triggering action. Could you please refer this?
JSON:
{
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"url": "https://demo-res.cloudinary.com/image/upload/sample.png",
"altText": "Navigation and Help",
"selectAction": {
"type": "Action.Submit",
"title": "Navigation and help",
"data": {
"msteams": {
"type": "imBack",
"value": "Can you help me with Navigation and Help"
}
}
},
"horizontalAlignment": "Center",
"width": "100px"
}
],
"height": "stretch",
"horizontalAlignment": "Center",
"spacing": "Padding"
},
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"url": "https://demo-res.cloudinary.com/image/upload/sample.png",
"altText": " Learning and development",
"selectAction": {
"type": "Action.Submit",
"title": "Learning and development",
"data": {
"msteams": {
"type": "imBack",
"value": "Can you help me with Learning and development"
}
}
},
"horizontalAlignment": "Center",
"width": "100px"
}
],
"horizontalAlignment": "Center",
"spacing": "Padding"
}
],
"style": "default",
"horizontalAlignment": "Center",
"spacing": "Padding",
"height": "stretch"
},
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.1"
}

Highcharts custom formatting/coloring of category labels

I need to be able to apply background coloring (and text coloring to maintain contrast) to category labels.
I couldn't find an easy way to set each category label independently and came up with a working solution but now the width of my label column is too wide and applying marginLeft doesn't work.
First is there an easier way to achieve what I want or a solution to the width.
Here's the result:
and fiddle can be found here
Highcharts.ganttChart('container', {
chart: {
// marginLeft: 400,
events: {
load: function() {
for (var tickPos in this.yAxis[0].ticks) {
console.log(tickPos);
var ch = this.yAxis[0].chart;
var tick = this.yAxis[0].ticks[tickPos];
var label = tick.label;
if (typeof label !== "undefined") {
var text = label.textStr;
var obj = JSON.parse(text);
var element = label.element;
element.textContent = obj.name;
if (typeof obj.background !== "undefined") {
element.style["background-color"] = obj.background;
}
if (typeof obj.color !== "undefined") {
element.style["color"] = obj.color;
}
}
}
}
}
},
title: {
text: 'Highcharts Gantt Chart'
},
subtitle: {
text: 'With linked to split'
},
xAxis: {
minPadding: 0.05,
maxPadding: 0.05
},
"yAxis": [{
"scrollbar": {
"enabled": true
},
labels: {
useHTML: true
},
"uniqueNames": true
}],
tooltip: {
outside: true
},
rangeSelector: {
enabled: true,
selected: 5
},
time: {
useUTC: true
},
plotOptions: {
column: {
grouping: true
}
},
"series": [{
"name": "main",
"tooltip": {
"headerFormat": null
},
"data": [{
"name": '{"name": "Color prep and printing", "background":"green", "color":"white"}',
"id": "_dqbcsMWXEeeTdKTuQU2hRA",
"start": 1577836800000,
"end": 1582934400000,
"color": {
"patternIndex": 0
}
}, {
"name": '{"name": "Send to color house", "background":"blue", "color":"white"}',
"id": "_dqkmv8WXEeeTdKTuQU2hRA",
"parent": "_dqbcsMWXEeeTdKTuQU2hRA",
"start": 1577836800000,
"end": 1580428800000,
"duration": 30
}, {
"name": '{"name": "Generate proofs", "background":"teal", "color":"white"}',
"id": "_dq3hkMWXEeeTdKTuQU2hRA",
"parent": "_dqbcsMWXEeeTdKTuQU2hRA",
"start": 1578614400000,
"end": 1579651200000,
"duration": 12,
"dependency": [{
"to": "_dqkmv8WXEeeTdKTuQU2hRA"
}]
}, {
"name": '{"name": "Print and ship", "background":"crimson"}',
"id": "_drLDlcWXEeeTdKTuQU2hRA",
"parent": "_dqbcsMWXEeeTdKTuQU2hRA",
"start": 1581292800000,
"end": 1582934400000,
"duration": 19,
"dependency": [{
"to": "_dq3hkMWXEeeTdKTuQU2hRA"
}]
}],
"dataLabels": [{}, {
"enabled": true,
"align": "right",
"format": "{point.duration}"
}]
}],
});
To increase the width, you can set width style:
yAxis: {
labels: {
useHTML: true,
style: {
width: '300px',
textOverflow: 'ellipsis'
}
},
...
},
Live demo: https://jsfiddle.net/BlackLabel/nkz9xmh0/
API Reference: https://api.highcharts.com/gantt/yAxis.labels.style

Highcharts stacked columns based on each day value

i'm trying to make a stacked column chart based on the following values
[
{
"date": "2019-06-08",
"profileId": "2978",
"likes": "48",
"source": "text",
"brand": "Pepsi",
"comments": "8",
"followers": "23443",
"ER": "1.00439"
},
{
"date": "2019-06-10",
"profileId": "6456",
"likes": "93",
"source": "media",
"brand": "pepsi",
"comments": "3",
"followers": "54482",
"ER": "0.99969"
},
{
"date": "2019-06-10",
"profileId": "6215",
"likes": "457",
"source": "media",
"brand": "pepsi",
"comments": "11",
"followers": "233113",
"ER": "1.00818"
}
]
and here's the chart object
const brandsValueChartOptions = {
chart: {
type: 'column',
}
credits: {
enabled: false,
},
xAxis: {
title: {
text: 'Date',
},
categories: brandsValue.x,
labels: {
formatter: function() {
return moment(this.value).format('Do MMM')
},
},
crosshair: true,
grouping: true
},
yAxis: {
min: 0,
title: {
text: 'Value (in USD)',
},
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span>',
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0,
stacking: 'normal',
},
},
series: {
stacking: 'true'
}
},
series: brandsValue.y,
}
and here how i process the data on the structure the results object to be used in the chart object above.
const brandsValue = {
x: [],
y: [],
}
let colorIndex = 0
_.chain(data)
.map(brand => {
return {
...brand,
day: brand.date,
brand: _.capitalize(brand.brand.toLowerCase()),
}
})
.forEach(brand => brandsValue.x.push(brand.day))
.groupBy(brand => brand.brand)
.forEach(items => {
if (values.mediaTypeSelected === 'posts') {
items.forEach(item => {
let followersCount = parseInt(item.followers)
let er = parseFloat(item.ER)
item.finalCost = 100 * er
item.date = new Date(item.date).getTime()
return item
})
}
})
.forEach(item => {
let sorted = _.sortBy(item, i => moment(i.date))
let values = {
name: item[0].brand,
color: "#cccccc",
data: [],
}
sorted.forEach(i => {
if (this.state.mediaTypeSelected === 'posts') {
values.data.push([
moment(i.date).format('Do MMM'),
parseInt(i.finalCost),
i.profileId,
])
}
})
brandsValue.y.push(values)
})
.value()
The problem here, is that the x-axis values aren't grouped/stacked based on the date, i've tried several solutions with no luck,
here's how the chart results looks like

Coloring Country while showing mappoint for cities in world map using highmaps

I am working with highmaps and have plotted the cities with map-points using lat-long for the same.
Now , I want to color particular countries say India and USA .
Is there any way to achieve the same ?
Below is my js file for plotting world map with citis mappoints with help of lat/lon
// Initiate the chart
$.getJSON("/MyProject/HighChartPhp/getMapData.php", function (data) {
// Correct UK to GB in data
$.each(data, function () {
if (this.code === 'UK') {
this.code = 'GB';
}
});
//console.log(data);
var final_array = [];
for(var i in data[0].data)
{
var map_data = {
name: data[0].name[i],
lat: data[0].lat[i],
lon: data[0].lon[i],
z: data[0].data[i],
val: data[0].loc[i],
color: data[0].color[i]
}
//console.log(map_data);
final_array[i] = map_data;
}
console.log(final_array);
Highcharts.mapChart('container', {
chart: {
borderWidth: 1,
map: 'custom/world'
},
title: {
text: 'Word Wide Data Usage'
},
subtitle: {
text: ''
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.val}</b><br/>{point.z}'
},
legend: {
enabled: false
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
series: [{
// Use the gb-all map with no data as a basemap
mapData: Highcharts.maps['custom/world'],
name: 'Basemap',
borderColor: 'green',
nullColor: 'rgba(200, 200, 200, 0.3)',
showInLegend: true
}, {
// Specify points using lat/lon
type: 'mappoint',
name: 'Cities',
//color: 'blue',
data: final_array
}]
});
});
How can I color India and US in the map ?
Tried the below , but still it is not working .
// Initiate the chart
$.getJSON("/MyProject/HighChartPhp/getMapData.php", function (data) {
// Correct UK to GB in data
$.each(data, function () {
if (this.code === 'UK') {
this.code = 'GB';
}
});
data.forEach(function(point, index) {
console.log("country="+point.country);
if (point.country === 'India' || point.country === 'United States') {
point.color = 'green';
}
});
//console.log(data);
var final_array = [];
for(var i in data[0].data)
{
var map_data = {
name: data[0].name[i],
lat: data[0].lat[i],
lon: data[0].lon[i],
z: data[0].data[i],
val: data[0].loc[i],
color: data[0].color[i],
country:data[0].country[i]
}
//console.log(map_data);
final_array[i] = map_data;
}
console.log(final_array);
Highcharts.mapChart('container', {
chart: {
borderWidth: 1,
map: 'custom/world'
},
title: {
text: 'Word Wide outsource Vendor Usage'
},
subtitle: {
text: ''
},
colorAxis: {
min: 1,
max: 1000,
type: 'logarithmic'
},
tooltip: {
headerFormat: '',
pointFormat: '<b>{point.val}</b><br/>{point.z}'
},
legend: {
enabled: false
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
series: [{
// Use the gb-all map with no data as a basemap
mapData: Highcharts.maps['custom/world'],
joinBy: ['iso-a2', 'code'],
name: 'Basemap',
borderColor: 'green',
nullColor: 'rgba(200, 200, 200, 0.3)',
showInLegend: true
}, {
// Specify points using lat/lon
type: 'mappoint',
name: 'Cities',
//color: 'blue',
data: final_array
}]
});
});
Below is json data :
"name": [
"Ahemdabad",
"Atlanta",
"Bangalore",
"Bangkok",
"Buenos Aires",
"Chennai",
"Chicago",
"Cochin",
"Colombo",
"Dallas",
"Delhi",
"Hyderabad",
"Irvine",
"Irvine Dallas",
"Johannesburg",
"Kolkata",
"Kuala Lumpur",
"Lima",
"Los Angeles",
"Miami",
"Moscow",
"Mumbai",
"New Jersey",
"New York",
"Niagra",
"Philadelphia",
"Rio",
"Riyadh",
"Seattle",
"Syracuse",
"Washington Baltimore"
],
"loc": [
"Ahemdabad:India",
"Atlanta:USA",
"Bangalore:India",
"Bangkok:Thailand",
"Buenos Aires:Argentina",
"Chennai:India",
"Chicago:USA",
"Cochin:India",
"Colombo:Sri Lanka",
"Dallas:USA",
"Delhi:India",
"Hyderabad:India",
"Irvine:USA",
"Irvine Dallas:USA",
"Johannesburg:South Africa",
"Kolkata:India",
"Kuala Lumpur:Malaysia",
"Lima:Peru",
"Los Angeles:USA",
"Miami:USA",
"Moscow:Russia",
"Mumbai:India",
"New Jersey:USA",
"New York:USA",
"Niagra:USA",
"Philadelphia:USA",
"Rio:Brazil",
"Riyadh:Saudi Arabia",
"Seattle:USA",
"Syracuse:USA",
"Washington Baltimore:USA"
],
"color": [
"#FFC300",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#49EC32",
"#FFC300",
"#EC3246",
"#FFC300",
"#EC32BF",
"#EC3246",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#16F7EC ",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#FFC300",
"#581845",
"#EC32BF",
"#EC32BF",
"#FFC300",
"#EC32BF",
"#EC32BF",
"#3A32EC",
"#EC32BF",
"#49EC32",
"#EC32BF",
"#EC32BF",
"#EC32BF",
"#EC32BF"
],
"lat": [
23.022505,
33.748995,
12.971599,
13.756331,
-34.603684,
13.08268,
41.878114,
9.931233,
6.927079,
32.776664,
28.704059,
17.385044,
33.684567,
33.684567,
-26.204103,
22.572646,
3.139003,
-12.046373,
34.052234,
25.76168,
55.755826,
19.075984,
40.058324,
40.712784,
43.082816,
39.952584,
-22.906847,
24.713552,
47.606209,
43.048122,
39.177404
],
"lon": [
72.571362,
-84.387982,
77.594563,
100.501765,
-58.381559,
80.270718,
-87.629798,
76.267304,
79.861243,
-96.796988,
77.10249,
78.486671,
-117.826505,
-117.826505,
28.047305,
88.363895,
101.686855,
-77.042754,
-118.243685,
-80.19179,
37.6173,
72.877656,
-74.405661,
-74.005941,
-79.074163,
-75.165222,
-43.172896,
46.675296,
-122.332071,
-76.147424,
-76.668392
],
"country": [
"India",
"USA",
"India",
"Thailand",
"Argentina",
"India",
"USA",
"India",
"Sri Lanka",
"USA",
"India",
"India",
"USA",
"USA",
"South Africa",
"India",
"Malaysia",
"Peru",
"USA",
"USA",
"Russia",
"India",
"USA",
"USA",
"USA",
"USA",
"Brazil",
"Saudi Arabia",
"USA",
"USA",
"USA"
]
}
You can add property to specific points from the data, before joining with mapData.
API Reference:
http://api.highcharts.com/highmaps/series%3Cmappoint%3E.data.color
Example:
http://jsfiddle.net/0Lcwn3pj/

Highcharts redraw not working with alignTicks

I have updated from version 2.1.6 to 4.0.4 and I have problem with refreshing the alignTicks option.
I start with the property at true and then I set it to false via a button.
From true to false the graph is only updated after a windows resize or if I disable/enable one set of data. From false back to true then it work correctly...
Here an example:
chart = new Highcharts.Chart({
'chart': {
'renderTo': 'graph',
'type': 'line',
'zoomType': 'x',
'alignTicks': true
},
'tooltip': {
'formatter': function () {
var d = new Date(this.x);
return 'Time: <b>' + ('0' + d.getUTCHours()).slice( - 2) + ':' + ('0' + d.getUTCMinutes()).slice( - 2) + ':' + ('0' + d.getUTCSeconds()).slice( - 2) + '</b><br/> Value: <b>' + this.y + '</b>';
}
},
'credits': false,
'title': {
'text': 'Date: 04-11-2014 - Location: Locale'
},
'xAxis': {
'type': 'datetime'
},
'yAxis': [
{
'title': {
'text': 'SK_angle',
'style': {
'color': '#4572A7'
}
},
'labels': {
'style': {
'color': '#4572A7'
}
},
'opposite': false,
'allowDecimals': true
},
{
'title': {
'text': 'EL_angle',
'style': {
'color': '#AA4643'
}
},
'labels': {
'style': {
'color': '#AA4643'
}
},
'opposite': true,
'allowDecimals': true
},
{
'title': {
'text': 'Software Status',
'style': {
'color': '#89A54E'
}
},
'labels': {
'style': {
'color': '#89A54E'
}
},
'opposite': false,
'allowDecimals': false
}
],
'series': [
{
'color': '#4572A7',
'name': 'SK_angle',
'yAxis': 0,
'data': [
[1415064918000,305.89],
[1415064919000,335.0],
[1415064923000,306.05],
]
},
{
'color': '#AA4643',
'name': 'EL_angle',
'yAxis': 1,
'data': [
[1415064918000,37.87],
[1415064919000,37.2],
[1415064923000,37.9],
]
},
{
'color': '#89A54E',
'name': 'Software Status',
'yAxis': 2,
'data': [
[1415064918000,1362],
[1415064919000,1362],
[1415064923000,1256],
]
}
]
});
$('#scaleAlign').click(function() {
if (chart.options.chart.alignTicks) {
chart.options.chart.alignTicks = false;
$('#scaleAlign').attr('value','Align Scale');
}
else {
chart.options.chart.alignTicks = true;
$('#scaleAlign').attr('value','Unalign Scale');
}
chart.isDirtyBox = true;
chart.redraw();
});
http://jsfiddle.net/04Lffe0r/3/
Update the code like this: http://jsfiddle.net/04Lffe0r/4/
By adding this:
chart.series[0].isDirty = true;
Because the series should be set as dirty for the chart to redraw.

Resources