I am developing an MS Teams bot using Bot Framework SDK in Node.js, the botfetches information from Airtable and send it to MS Teams bot. I am using VS Studio Code Teams Toolkit extension to create, provision and deploy the bot.
I am facing a problem sending video attachments from Airtable to the bot. I have tried the following methods
- getInternetAttachment function from BotBuilder's GitHub repository but it gives
Unknown attachment type
error.
async function getInternetAttachment(file_url) {
// NOTE: The contentUrl must be HTTPS.
return {
name: "file.mp4",
contentType: "video/mp4,
contentUrl: file_url
};
}
I have changed the value of
supportsFile:true
in manifest.json. Didn't have any affect on the bot.I have tried creating a video card but it gives
Malformed Video card - Invalid aspect value
error
async function createVideoCard(title, url) {
return CardFactory.videoCard(
title,
[{ "url": url }],
[{
"type": 'openUrl',
"title": 'Lean More',
"value": 'https://channel9.msdn.com/Events/Imagine-Cup/World-Finals-2018/2018-Imagine-Cup-World-Championship-Intro'
}],
{
"subtitle": 'by Microsoft',
"text": 'Microsoft\'s Imagine Cup has empowered student developers around the world to create and innovate on the world stage for the past 16 years. These innovations will shape how we live, work and play.'
}
);
}
await turnContext.sendActivity({ attachments: [await createVideoCard(title, url)] })
Fetching attachments from Airtable:
const records = await base(course_tn).select({
view: "Grid view",
}).all(
);
records.forEach(async function (record) {
files= record.get("Attachments") //Attachments is the field name
console.log(files)
const reply = { type: ActivityTypes.Message };
reply.attachments = [await getInternetAttachment(files.url)];
turnContext.sendActivity(reply)
})
Output:
[
{
id: 'attAm7ezFldMnS7uC',
url: file_url,
filename: 'SampleVideo_1280x720_10mb.mp4',
size: 10498677,
type: 'video/mp4'
}
]
Airtable API reference: https://support.airtable.com/hc/en-us/articles/203313985-Public-REST-API
Each method and code runs successfully in the Bot Framework emulator. How can I resolve this and successfully send video attachments from Airtable to MS Teams bot?