Send pdf with smba trafficmanager or botframework - botframework

I'm trying to send pdf file as attachment proactively to teams user with https://smba.trafficmanager.net/in/v3/conversations/ and attachment format as below
"attachments": [
{
"contentType": "application/pdf",
"contentUrl": "http://www.africau.edu/images/default/sample.pdf",
"name": "sample.pdf",
"content": {
"uniqueId": "1150D938-8870-4044-9F2C-1213213123",
"fileType": "pdf"
}
}
]
I'm able to send txt files but not pdf, every time I'm getting
{"error":{"code":"BadArgument","message":"Unknown attachment type"}}
Is there any other contentType other than application/pdf ?

I agree with Hilton and Dev here. I think it's more convenient to post messages with card attachments referencing existing SharePoint files using the Microsoft Graph APIs.
MS documents referred to 2 ways for bots send attachment. Using the Microsoft Graph APIs works for bots in all scopes in Teams while using the Teams APIs works only in the personal context.
By the way, the document says pdf is ok to be a file type.

#kiran, The below payload works for me. So i am adding the payload for your convenience (below), so that you can copy/test it.
{ "body": { "contentType": "html", "content": "Here's the latest budget. <attachment id=\"153fa47d-18c9-4179-be08-9879815a9f90\"></attachment>" }, "attachments": [ { "id": "153fa47d-18c9-4179-be08-9879815a9f90", "contentType": "reference", "contentUrl": "m365x987948.sharepoint.com/sites/test/Shared%20Documents/…", "name": "Budget.pdf" } ] }

Based on the discussion in the comments, it is definitely better to rather provide a link to the document, hosted in SharePoint (files tab) - that's exactly what the Files tab is intended for, rather than every user having to download their own copy. In addition, have a look at the topic of Link Unfurling to see how to provide a better embedded experience for the posted file.

Related

Adaptive Card Action.OpenUrl not working for certain URLs in Microsoft Teams bot

I am working on a Microsoft Teams chat bot using Microsoft Bot Framework. The bot sends an Adaptive Card containing some text and the following Action:
{
"type": "ActionSet",
"actions": [
{
"type": "Action.OpenUrl",
"title": "View in dashboard",
"url": "${url}"
}
]
},
The URL is of the following form (edited to remove identifying info):
https://internaldomain.net/dashboard/share/134590h9?overrides=[{"query":"//dataSources","key":"account","replacement":"accountName"},{"query":"//*[id='Cluster']","key":"value","replacement":"clusterId"},{"query":"//*[id='NodeId']","key":"value","replacement":"nodeId"},{"query":"//*[id='ContainerId']","key":"value","replacement":"containerId"}]&globalStartTime=1591552800000&globalEndTime=1592460000000&pinGlobalTimeRange=true
The URL is generated and passed into the url property using a JSON templating library, and I can print the URL in the console so I know it is set properly. Also, I can run the bot in the Emulator and open the link that way. However, when I run the bot in Teams and try to open the same exact link by clicking the action button, nothing happens. If I change what URL is passed in, e.g. using https://internaldomain.net/dashboard, the link works correctly.
One thought is that the generated URL is formatted improperly so Teams doesn't recognize it or open it. But I can paste it into a browser and it opens properly.
Another thought is that the URL length (almost 500 chars) exceeds some limit for Adaptive Cards, but I haven't been able to find any info about that in the documentation or online.
I would appreciate any other ideas about what might be causing this.
Thanks!
It looks like you're needing to encode the urls before embedding them - probably the {"query" etc. is conflicting with the final Json. It looks like you're using .Net, so you could call WebUtility.UrlEncode, on everything from "?" onwards (i.e. "?overrides...")

Apostrophes in title attribute are HTML encoded in response

"snippet": {
"publishedAt": "2012-08-24T17:06:35.000Z",
"channelId": "UCh6C5LG14uZKmwCgGxf-nDQ",
"title": "Céline Dion - I'm Alive (Official Video)",
"description": "Celine Dion - I'm Alive (Official Video) Listen on Spotify: http://smarturl.it/Celine_Spotify_EN Listen on Apple Music: http://smarturl.it/Celine_AM_EN Amazon: ...",
"thumbnails": {},
}
Any Idea why this is happening? It's well decoded into the description but not the title field
This has been a known issue of the API for quite some time.
Other users experienced it -- including myself. Yet, no documenting explanation and/or solution from Google emerged (as far as I know), neither here on SO, nor on Google's own issue tracker site.
I myself am filtering the texts received from API endpoints through my own HTML entity decoder.
I recommend you do the same kind of cleaning-up, using tools available from the surrounding programming environment.
As a final note, interestingly enough, on my site your video does not produce HTML entities in the JSON text obtained from the API.

How to send a local file path thorugh the QnA Create Knowledgebase API?

I am referring to this QnA create knowledgebaseAPI documentation. I want to upload the knowledge base through the Excel file which is stored in the local path. I don't have URL for the excel file, only the local path.
I followed the code given on github link, I removed the unnecessary things and kept the variable "kb" as shown below:
static string kb = $#"
{{
'name': 'VivekKB',
'qnaList': [],
'urls': [ ],
'files': [
'files': {{DBFile}}
]
}}
DBFile is the filename with full path. When I run the code, it creates an Empty knowledge store. It doesn't upload the excel file which I mentioned. Can you please help me to figure it out how to upload a local excel QnA data directly to QnA store. I want to avoid manual uploading excel to knowledgebases at https://www.qnamaker.ai.
Thanks in advance.
Vivek
Connected with the QnA team directly, asking the following:
Question: Is it possible to use a local file path to create KB through the programmatic API?
I know given in the programmatic QnA API docs it demonstrates how to add a PDF file that’s already also available online as well:
"files": [
{
"fileName": "SurfaceManual.pdf",
"fileUri": "https://download.microsoft.com/download/2/9/B/29B20383-302C-4517-A006-B0186F04BE28/surface-pro-4-user-guide-EN.pdf"
}
However when I tried using “POST Create Knowledgebase “ in Postman using the relative file path in the “fileUri”, I get “invalid uri” error.
Request Body
{
"name": "Simple QnA",
"files": [
{
"fileName": "simpleQnaSource.docx",
"fileUri": "C:\\Users\\v-asho\\Documents\\RandomWordDocs"
}
]
}
Response
{
"error": {
"code": "BadArgument",
"message": "Invalid input. See details.",
"details": [
{
"code": "ValidationFailure",
"message": "File Uri has one or more invalid uri.",
"target": "Files[0].FileUri"
}
]
}
}
Uploading the .docx file online through qnamaker.ai portal successfully creates a KB, it’s specifically through the programmatic api where I’m having issues.
QnA Team's Answer:
“fileUri” can have a publicly available and downloadable URI as value.
When using it via API, please upload the contents of local file to a publicly available domain. (Example: Azure storage blob shared to public).

Google Drive: where are my comments?

The Google API does seem to permit to create comments and replies on any type of files (including binary files)
Also, I can publicly share a link and grant anonymous users having the link the permission to view and comment this file. This is the case of this picture with id=0BxMiPUSrDs2EMWVUQkR3cWsxRWs, yet, browsing this url as an anonymous user, I don't really know where are the comments and how to send a new comment.
Using this Drive API, I successfully created a comment:
POST https://www.googleapis.com/drive/v3/files/fileId/comments
Using this Drive API, I successfully listed the file comments:
GET https://www.googleapis.com/drive/v3/files/fileId/comments
Result is:
{
"comments": [
{
"kind": "drive#comment",
"id": "AAAAA-ZIom0",
"createdTime": "2017-03-28T17:21:18.008Z",
"modifiedTime": "2017-03-28T17:21:18.008Z",
"author": {
"kind": "drive#user",
"displayName": "Sébastien Lorber",
"photoLink": "//ssl.gstatic.com/s2/profiles/images/silhouette96.png",
"me": true
},
"htmlContent": "Hello world",
"content": "Hello world",
"deleted": false,
"resolved": false,
"replies": []
}
]
}
So it seems this file does have a comment.
The problem is that, when using both the Drive web UI, and the Drive Android application, I am totally unable to access the content of this comment.
I can only see the comment appears as an entry inside the file activity log, so the Drive UI does know that there is a comment, but I am totally unable to find a way to read the comment content Hello world inside the official UIs.
So: am I missing something, or the Drive comment system is only to be considered as a SaaS backend for comments and the official UIs do not care of the comments we created (unless they are special kind of files, like Google Docs files).
Is there any Drive application out there that actually does show Drive comments for any kind of file?
Google Drive Comments:
View all comments:
Open a document, spreadsheet, or presentation.
In the top right, click Comments.
To close, click Comments again.
This issue is in how Google Drive works. Google drive only displays comments for the following types of files document, spreadsheet, or presentation.
While the API may allow you to add a comment Drive wont display it.
These comments should now be shown directly in the Drive UI: https://gsuiteupdates.googleblog.com/2018/02/comment-on-files-in-drive-preview-mode.html

Microsoft Azure Graph API download itemAttachment content

When I open email message in the office365 web browser page, there is an option to DOWNLOAD contents of the attached to this email itemAttachment ( another message attached to the current one using Microsoft Outlook ) - *.eml file, (contentType: RFC-822).
However, when I'm trying to get the contents of this itemAttachment through Graph API (same operation), the contentBytes response property is not present.
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#users('bbbbb')/messages('fffff')/attachments",
"value": [{
"#odata.type": "#microsoft.graph.itemAttachment",
"id": "gggg",
"lastModifiedDateTime": "2017-02-13T16:29:45Z",
"name": "The Daily Build - Compiling your C code to .NET",
"contentType": "message/rfc822",
"size": 99129,
"isInline": false
}
]
}
Any ideas how to get contents of attached outlook message though Graph API ( contentType=itemAttachment )? The fileAttachment contentType is working fine, I can grab the contents from the contentBytes property of the Graph API response. The following API endpoints are considered:
https://graph.microsoft.com/beta/me/messages/{id}/attachments
https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}
https://graph.microsoft.com/beta/me/messages/{id}/attachments/{attachmentId}?$expand=#microsoft.graph.itemAttachment/item
neither of the above returns contents of the attached Item.
It's in beta and there isn't a documentation, but you can get MIME content with Microsoft Graph API:
GET https://graph.microsoft.com/beta/me/messages/{id}/$value
or
GET https://graph.microsoft.com/beta/users/{id | userPrincipalName}/messages/{id}/$value
Attachments:
GET https://graph.microsoft.com/beta/users/{id}/messages/{id}/attachments/{id}/$value
With the response you can create a file with .eml extension.
Edit:
Now it's officially in preview: https://learn.microsoft.com/en-us/graph/outlook-get-mime-message

Resources