Servicenow and Microsoft Teams Integration with Adaptive Card
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2025 01:29 PM
Team,
The Microsoft Teams Graph Spoke plugin has been installed and set up, and everything works fine when posting messages to the chat. However, I encountered a process automation error when trying to post an Adaptive Card. I cloned the 'Post Message to Chat' action and created a new script include, 'MSTeamsGraphMessageBuilderCustom()', since the out-of-the-box version is read-only. Despite this, the issue persists, as shown below:
{ "Action Status": { "code": 1, "message": "Error: Missing body content (Process Automation.af701e4c333f9a5017ee27cb9d5c7b6b; line 12)" } }
I’m using the example below and am unsure if something is missing from the body or content of the JSON. Has anyone already resolved this issue?
Here is the example of adaptive cards - link
======================== Flow Designer Action =============================
(function execute(inputs, outputs) {
var util = new MSTeamsUtil();
var trimInputs = MSTeamsGraphMeetingUtils.trimInputs(inputs);
var mandatoryFields = {
"Chat ID": trimInputs.chat_id,
"Message": trimInputs.message
};
var mandatoryFieldResult = MSTeamsGraphMeetingUtils.checkMandatoryFields(mandatoryFields);
if (mandatoryFieldResult != "")
throw new Error("Following fields are mandatory - " + mandatoryFieldResult);
var obj = util.processMentions(inputs.mentions, inputs.message);
trimInputs.mentions = obj.mentions;
trimInputs.message = obj.message;
var hostedContent = {};
if (inputs.inline_image_attachment)
util.processAttachment(inputs.inline_image_attachment, hostedContent, trimInputs.inline_image_attachment_type);
//var payload = new MSTeamsGraphMessageBuilder();
var payload = new MSTeamsGraphMessageBuilderCustom();
outputs.message = payload.getPayloadForMSMessageCustom(trimInputs.title, trimInputs.message, hostedContent, trimInputs.sharepoint_attachment, trimInputs.mentions);
outputs.chat_id = trimInputs.chat_id;
})(inputs, outputs);
======================== Script Include =============================
getPayloadForMSMessageCustom: function(title, message, hostedContent, reference_attachment, mentions) {
var obj = {
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [{
"type": "Container",
"items": [{
"type": "TextBlock",
"text": "Publish Adaptive Card schema",
"weight": "bolder",
"size": "medium"
},
{
"type": "ColumnSet",
"columns": [{
"type": "Column",
"width": "auto",
"items": [{
"type": "Image",
"url": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
"size": "small",
"style": "person"
}]
},
{
"type": "Column",
"width": "stretch",
"items": [{
"type": "TextBlock",
"text": "Matt Hidinger",
"weight": "bolder",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "none",
"text": "Created {{DATE(2017-02-14T06:08:39Z, SHORT)}}",
"isSubtle": true,
"wrap": true
}
]
}
]
}
]
},
{
"type": "Container",
"items": [{
"type": "TextBlock",
"text": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
"wrap": true
},
{
"type": "FactSet",
"facts": [{
"title": "Board:",
"value": "Adaptive Card"
},
{
"title": "List:",
"value": "Backlog"
},
{
"title": "Assigned to:",
"value": "Matt Hidinger"
},
{
"title": "Due date:",
"value": "Not set"
}
]
}
]
}
],
"actions": [{
"type": "Action.ShowCard",
"title": "Set due date",
"card": {
"type": "AdaptiveCard",
"body": [{
"type": "Input.Date",
"id": "dueDate"
}],
"actions": [{
"type": "Action.Submit",
"title": "OK"
}]
}
},
{
"type": "Action.ShowCard",
"title": "Comment",
"card": {
"type": "AdaptiveCard",
"body": [{
"type": "Input.Text",
"id": "comment",
"isMultiline": true,
"placeholder": "Enter your comment"
}],
"actions": [{
"type": "Action.Submit",
"title": "OK"
}]
}
}
]
}
}
return JSON.stringify(obj);
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 09:31 PM
Hi @User267392 ,
Could you please share the request body (from the failed action/flow execution) that is being sent to Teams? You can use dummy values for the chat ID. Reviewing the request body will help us understand how the inputs are being passed.
Additionally, please verify these two points, as they might help in resolving the issue (both are also mentioned in the action description):
- A message will be sent as a card only if a value is specified for the Title. Ensure that the Title is not empty.
- When sending a message as a card, the mention feature is not supported. Make sure no entities are mentioned in the message input.