How to use customized cards with Microsoft Teams webhook - post

Adaptive cards receive "bad request 400" error
I'm trying to send a POST request from AWS Lambda running Python 3.7 using the urlopen method
I have a regular card request that is working but an adaptive card will hit the error mentioned above.
Example of working card:
{'#context': 'https://schema.org/extensions', '#type': 'MessageCard', 'themeColor': 'd63333', 'title': 'Red Alert - There is an issue Example alarm name', 'text': 'Example alarm name has changed from OK to ALARM - Threshold Crossed: 1 datapoint (10.0) was greater than or equal to the threshold (1.0).'}
Example of customized card (getting bad request error - 400):
{'#context': 'https://schema.org/extensions', '#type': 'AdaptiveCard', 'padding': 'none', 'body': [{'type': 'Container', 'style': 'emphasis', 'items': [{'type': 'ColumnSet', 'columns': [{'type': 'Column', 'items': [{'type': 'Image', 'horizontalAlignment': 'Right', 'url': 'https://miro.medium.com/max/1000/1*sszpZOih_xJV_lZsDbog-Q.png', 'height': '50px', 'altText': 'MC Logo'}], 'width': 'auto'}]}]}, {'type': 'Container', 'padding': {'top': 'none', 'left': 'default', 'bottom': 'default', 'right': 'default'}, 'items': [{'type': 'Container', 'items': [{'type': 'ColumnSet', 'spacing': 'Large', 'separator': 1, 'columns': [{'type': 'Column', 'verticalContentAlignment': 'center', 'items': [{'type': 'Image', 'horizontalAlignment': 'Center', 'style': 'Person', 'url': 'https://www.sccpre.cat/mypng/detail/57-574129_4-warning-stamp-vector-png-transparent-svg-warning.png', 'width': '60px', 'altText': 'warning logo'}], 'width': '60px'}, {'type': 'Column', 'items': [{'type': 'TextBlock', 'size': 'Medium', 'text': 'Example alarm name issue description', 'wrap': 1}, {'type': 'TextBlock', 'spacing': 'None', 'text': 'MC ETL Process notifier', 'isSubtle': 1}], 'width': 'stretch'}]}, {'type': 'FactSet', 'facts': [{'title': 'Incident time:', 'value': '06/07/2019 03:10:12 AM CT'}, {'title': 'Component:', 'value': 'AWS Glue - insert funds job'}, {'title': 'Overall nightly done:', 'value': '73%'}]}, {'type': 'TextBlock', 'spacing': 'Small', 'weight': 'Bolder', 'color': 'Accent', 'size': 'Medium', 'text': 'Click to restart'}, {'type': 'TextBlock', 'spacing': 'Small', 'weight': 'Bolder', 'color': 'Accent', 'size': 'Medium', 'text': 'Click to review logs'}]}]}], 'version': '1.0'}
What is wrong with my POST request?

Currently, Teams incoming Webhooks does not support Adaptive Cards. You can send only Message Card in connector messages. We are working on the Adaptive Card support but do not have timeline to share.

Related

Outlook REST API returns events without start and end dates

When requesting GET https://outlook.office.com/api/v2.0/me/calendars/{calendar_id}/events the response (for some events) does not have a Start and End date.
The full structure for such events is as follows:
{
'OriginalStartTimeZone': None,
'End': {
'TimeZone': 'tzone://Microsoft/Utc',
'DateTime': '0001-01-01T00:00:00.0000000Z'
},
'HasAttachments': False,
'ResponseRequested': True,
'ShowAs': 'Free',
'Recurrence': None,
'Start': {
'TimeZone': 'tzone://Microsoft/Utc',
'DateTime': '0001-01-01T00:00:00.0000000Z'
},
'BodyPreview': '',
'AllowNewTimeProposals': True,
'Location': {...},
'Attendees': [...],
'TransactionId': None,
'Type': 'SingleInstance',
'ResponseStatus': {
'Response': 'NotResponded',
'Time': '0001-01-01T00:00:00Z'
},
'Body': {...},
'OnlineMeeting': None,
'IsRoomRequested': False,
'OnlineMeetingProvider': 'Unknown',
'IsCancelled': False,
'IsAllDay': False,
'ReminderMinutesBeforeStart': 0,
'Subject': '...',
'Categories': [],
'LastModifiedDateTime': '2020-03-11T18:31:15.548Z',
'AutoRoomBookingOptions': None,
'OriginalEndTimeZone': None,
'CreatedDateTime': '2020-03-11T18:34:34.259429Z',
'IsOnlineMeeting': False,
'#odata.id': '...',
'IsDraft': False,
'WebLink': '...',
'ChangeKey': '...',
'SeriesMasterId': None,
'IsOrganizer': True,
'iCalUId': None,
'AutoRoomBookingStatus': 'None',
'Locations': [],
'Id': '...',
'IsReminderOn': False,
'Calendar#odata.associationLink': '...',
'Calendar#odata.navigationLink': '...',
'Importance': 'Normal',
'Organizer': {...},
'#odata.etag': '...',
'Sensitivity': 'Normal',
'OnlineMeetingUrl': None
}
Is this normal behavior? If so, how can this be displayed?
How can I create such an event to reproduce it?

HIghchart Treemap - Add double click event on legend click

Pls find the link for treemap http://jsfiddle.net/BlackLabel/m0587v4q/.
What I need is when I double click on legend it should show that respective data only on tree map and rest should hide.
$('#container').highcharts({
'chart': {
type: 'treemap'
},
series: [{
data: [{
'name': 'Americas',
'value': 52976,
'color': 'rgba(47,126,216,1)'
}, {
'name': 'Australia',
'value': 41219,
'color': 'rgba(13,35,58,1)'
}, {
'name': 'Europe',
'value': 62756,
'color': 'rgba(139,188,33,1)'
}, {
'name': 'Asia',
'value': 14577,
'color': 'rgba(145,0,0,1)'
}],
legendType: 'point',
showInLegend: true
}]
});
You can use Custom-Events plugin and add double click event in this way:
legend: {
itemEvents: {
dblclick: function() {
console.log('dblclick')
},
click: function() {
console.log('click')
}
}
}
Live demo: http://jsfiddle.net/BlackLabel/6m4e8x0y/4952/
Docs: https://www.highcharts.com/plugin-registry/single/15/Custom-Events

Checking if variable exists in Rails 5 GET request

Not sure exactly how to ask this as I am learning as I go. I am creating/updating user information from my app to a third party CRM system.
I have two methods that run successfully with an after_save callback. During testing, I would comment one out so I can test the other but now I need to combine them with an if else statement.
What should happen when combined together is when User is saved, the system will see if a user exists on the CRM system - if agile_id?. If user exists, it will skip down to the update call and send over any updated contact data, but if it doesn't, it will create a new CRM contact record.
The error I am receiving in the browser is:
undefined method `agile_id?' for #<User:0x007ffe24cef318>
user.rb
...
after_save :sync_to_agilecrm
...
def sync_to_agilecrm
agile_id = AgileCRM.request :get, 'contacts/search/email/'+email, nil
if agile_id?
contact_data = {
'properties': [
{ 'type': 'SYSTEM', 'name': 'first_name', 'value': first_name },
{ 'type': 'SYSTEM', 'name': 'last_name', 'value': last_name },
{ 'type': 'SYSTEM', 'name': 'email', 'subtype': 'work', 'value': email },
{ 'type': 'SYSTEM', 'name': 'address', 'value': '{\"address\":\"225 George Street\",\"city\":\"NSW\",\"state\":\"Sydney\",\"zip\":\"2000\",\"country\":\"Australia\"}' },
]
}
parsed_contact_data = JSON.parse(contact_data.to_json)
print(AgileCRM.request :post, 'contacts', parsed_contact_data)
else
update_contact_data = {
'id': agile_id,
'properties': [
{ 'type': 'SYSTEM', 'name': 'first_name', 'value': first_name },
{ 'type': 'SYSTEM', 'name': 'last_name', 'value': last_name },
{ 'type': 'SYSTEM', 'name': 'email', 'subtype': 'work', 'value': email },
{ 'type': 'SYSTEM', 'name': 'address', 'subtype': 'work', 'value': address_line1 },
]
}
parsed_update_contact_data = JSON.parse(update_contact_data.to_json)
print(AgileCRM.request :put, 'contacts/edit-properties', parsed_update_contact_data)
end
end
...
agile_id and agile_id? aren't the same thing. You'll sometimes see ActiveRecord objects which have record.attribute? which is enabled through some meta programming.
So, when defining a variable such as agile_id, adding a question mark on the end won't just work, nor is it needed. a simple if agile_id should be sufficient.

Highcharts.js: Customization of Funnel

I make a funnel with this script
$(function () {
$('#container').highcharts({
chart: {
type: 'funnel',
marginRight: 100
},
title: {
text: 'Sales funnel',
x: -50
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '<b>{point.name}</b> ({point.y:,.0f})',
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black',
softConnector: false
},
neckWidth: '2%',
neckHeight: '0%',
//-- Other available options
//height: pixels or percent
width: '100%'
}
},
legend: {
enabled: false
},
series: [{
name: 'Unique users',
data: [
['Item 1', 15005],
['Item 2', 1681],
['Item 3', 1254],
['Item 4', 1165],
['Item 5', 800],
['Item 6', 60],
['Item 7', 202],
]
}]
});
});
http://jsfiddle.net/fainz777/j7p76n6r/1/
If it possible to make it to this view http://c2n.me/38zvhae ?
Each bar have equal height and only width depends on value.
Thanks for help.
There is no function in Highcharts API to make that chart. Funnel type chart has only one change in width from tapered to straight.
Instead you can try to use area range type chart.
JSFiddle: http://jsfiddle.net/rb4j0unv/
$(function () {
$('#container').highcharts({
chart: {
type: 'arearange',
inverted: true,
zoomType: 'x'
},
legend: {
enabled: false
},
series: [{
data: [{low:-100, high:100, x: 0},{low:-50, high:50, x: 1}]
},{
data: [{low:-50, high:50, x: 1},{low:-40, high:40, x: 3}]
},{
data: [{low:-40, high:40, x: 3},{low:0, high:0, x: 4}]
}]
});
});

highcharts basics

I have the following data fetched in the array using php and my sql
Array
(
[name] => Array
(
[0] => a
[1] => b
)
[data] => Array
(
[0] => Array
(
[0] => 0
[1] => 1
[2] => 2
[3] => 3
[4] => 4
[5] => 5
[6] => 6
)
[1] => Array
(
[0] => 34
[1] => 35
[2] => 36
[3] => 37
[4] => 38
[5] => 39
[6] => 40
)
)
)
I am new to highcharts and jquery.
The function for the line plot is
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y +'°C';
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
},
series: [{
name: 'Tokyo',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
name: 'New York',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
name: 'Berlin',
data: [-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: 'London',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}]
});
});
});
</script>
I don't know how to pass my data for a and b so that it can line plot
Need it urgent .. thanks
Use the following to get your array parsed to js.
var data = jQuery.parseJSON(' <?php echo json_encode($yourArray, JSON_NUMERIC_CHECK); ?> ');
Than you can put it inside your serie like the following.
series: [{
'name': data.name[0],
'data': data.data[0]
}, {
'name': data.name[1],
'data': data.data[1]
}]

Resources