I am new to using azure bot service
I have a bot that is used inside Microsoft Teams
I use this bot to send and receive messages inside Microsoft teams
When the user tags the bot and sends a text message I get it in the activity response
But when the user tags the bot and sends an image attached to the message I do not get any information about that image
"attachments" : [ {
"contentType" : "text/html",
"content" : "<div><div><span itemscope=\"\" itemtype=\"http://schema.skype.com/Mention\" itemid=\"0\">BotName12</span> Msg </div>\n</div>"
} ],
above is what I get ,
I expect to get also "contentUrl","content" and "thumbnailUrl"
Is it related to permissions ? If so, where do I define it,
On the Bot, or on the Application related to it?
Thanks
I tried to reproduce the procedure and the image is being uploaded perfectly and the text message also sent successfully in MS Teams.
Follow the instructions mentioned below screen.
Click on Channels to choose MS Teams
Select Microsoft Teams and attach the created bot to Teams Channel. After channel attachment, click on open in teams
The above procedure may not be the code part, but the procedure to create the bot and attach to teams perfectly.
The required contentType and other attachments information can be retrieved by setting name property and contentUrl property to the URL related to the media file. content, contentType, contentUrl, name, thumbnailUrl are the properties need to be given. Then the Activity object which is responsible for your message will specify the Attachment object within your attachments array.
For example, consider the following code for the single image upload.
POST https://your-website/apis/v3/conversations/abcd1234/activities/5d5cdc723
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json
Here comes, the JSON response for the content uploaded as an attachment
{
"type": "message",
"from": {
"id": "234567",
"name": "sender's name"
},
"conversation": {
"id": "user234",
"name": "conversation's name"
},
"recipient": {
"id": "bot234",
"name": "recipient's name"
},
"text": "Here's a picture of the duck I was telling you about.",
"attachments": [
{
"contentType": "image/jpg",
"contentUrl": "image URL"
}
],
"replyToId": "234"
}
To implement different types of media cards if needed refer. We can include AudioCards as well.
Related
I'm Using an invite API from MS GRAPH - Invite LINK
Send a sharing invitation – External users
POST /me/drive/items/{item-id}/invite
POST /sites/{siteId}/drive/items/{itemId}/invite
The responses from the above request returns 200 OK response code and a permission object is returned , but the Sharing link(webUrl) under the link object returns “null” most of the times due to which the shareable link cannot be shared to External user for editing the document.
REQUEST BODY:
{
"recipients": [
{
"email": "abc#abc.com"
}
],
"message": "Here's the file that we're collaborating on.",
"requireSignIn": true,
"sendInvitation": false,
"roles": [ "write" ]
}
Here i don't want to share the item throgh mail hence making sendInvitation false and using the webURL recevied from response for collaboration.
Observation :
It works with gmail and outlook account.
For business accounts it's not working receiving url as null.
Samples:
If i invite for the first time , i'm getting below response ,
Sample Excepted Response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(permission)",
"value": [
{
"#odata.type": "#microsoft.graph.permission",
"roles": [
"write"
],
"grantedToIdentities": [
{
"user": {
"email": "##########.com"
}
}
],
"invitation": {
"signInRequired": true
},
"link": {
"type": "edit",
"webUrl": "https://**********encryptedURL*****/"
}
}
]
}
From the second time link object not coming in the response,
Sample Response Received Without webURL:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(permission)",
"value": [
{
"#odata.type": "#microsoft.graph.permission",
"id": "###############",
"roles": [
"write"
],
"grantedTo": {
"user": {
"email": "#############.com",
"id": "#############",
"displayName": "#######"
}
}
}
]
}
i resolved my problem by using the upload API LINK
, once upload is successful the API returns response which will have "webUrl" link that can be used to share from second time.
(After exploring more with MS GRAPH API's observed that if we are
sharing the same file multiple times it will not give any new link as
the old link only can be used )
Actual Flow : Upload File -> Share File (this was happening everytime)
Changed Logic : First time : Upload File -> Share file
Second Time onwards : as file is already shared , using the url from upload API Response
As file is already shared with user for the first time hence the url which we are getting as response from UPLOAD API can be used , this url can be accessible by already shared user.
So i changed my logic if the user performing the operation for first time then i'm uploading file and sharing with him , if the user wants to perform same operation again instead of sharing the file again using the upload response url it works for me.
Posting this solution as it might help someone
I am trying to build a Slack app by using AWS lambda and NodeJs. The issue I am facing is that I don't understand in what format does the SlackBot need the JSON payload from my AWS lambda code to display it.
I followed the tutorial video suggested on Slack linked here. In the video, the following JSON object is created and returned from the AWS lambda.
const response = {
statusCode: 200,
body: "Sample Response",
};
The SlackBot posts the text entered in the 'body' property (i.e. 'Sample Response' in this case) as a response. This seems to be working well. But, I need some more flair than simple text so I looked into their Block Kit UI builder. But there seems to be no documentation for how to do this with a similar 'response' JSON object like this. How exactly am I supposed to use the JSON object created by the UI builder?
I do not know much about Web development so sorry if this seems like a very basic question. I wish there was a sample Slack app on their website which showed this.
The following may work for you (I use a similar one on the production);
{
"channel": "your-channel-name",
"username": "channel-username",
"attachments": [
{
"title": "some-title",
"fallback": "some message",
"text": "some text",
"fields": [
{
"title": "sub-title",
"value": "sub-title-value",
"short": true
},
{
"title": "some-other-title",
"value": "some-value"
}
],
"color": "red"
}
],
"icon_emoji": "gun"
}
This link or this one may provide some extra information.
I am having difficulty interpreting the results of the webhook event data being returned. If this is the data being returned:
{
"name":"Test Webhook",
"event_id":"EVENT ID HERE",
"object_type":"response",
"object_id":"OBJECT ID HERE",
"event_datetime":"2017-01-12T15:10:18.667701+00:00",
"event_type":"response_completed"
}
I understand that the object_id corresponds to the responseId but I am trying to figure out where the surveyId is?
When we get the event data back, we need to make an API call to:
'surveys/'.$surveyId.'/responses/'.$responseId.'/details' so that we can get the details for processing.
Any help is greatly appreciated.
The webhook data sent to your subscription URL has recently been updated. See the details in the docs.
The payload has some new values, it looks something like this now (depending on your event type):
{
"name": "My Webhook",
"filter_type": "collector", (or survey, it's based on how they configure the webhook)
"filter_id": "123456789",
"event_type": "response_completed",
"event_id": "123456789",
"object_type": "response",
"object_id": "123456",
"event_datetime": "2016-01-01T21:56:31.182613+00:00",
"resources": {
"respondent_id": "123456789",
"recipient_id": "123456789",
"collector_id": "123456789",
"survey_id": "123456789",
"user_id": "123456789"
}
}
So if your event was "response_completed" then object_id is the response ID. If you filtered to a specific type of survey then the filter_id is the survey ID.
As well there is a resources key with a bunch of relevant IDs.
I'm using the Docusign API (via the ruby docusign_rest gem) and repro'd this using Postman.
I have an envelope whose name has quotes in it. When I tried to download the signed PDF, I get an error message:
https://www.docusign.net/restapi/v2/accounts/{account_id}/envelopes/{envelope_id}/documents/1
{
"errorCode": "UNSPECIFIED_ERROR",
"message": "The format of value 'file; filename=\"My filename (\"MF\") has quotes.pdf\"; documentid=\"1\"' is invalid."
}
When I list the documents, it shows the name of the envelope having quotes.
https://www.docusign.net/restapi/v2/accounts/{account_id}/envelopes/{envelope_id}/documents
{
"envelopeId": "{envelope_id}",
"envelopeDocuments": [
{
"documentId": "1",
"name": "My filename (\"MF\") has quotes.pdf",
"type": "content",
"uri": "/envelopes/{envelop_id}/documents/1",
etc...
}
}
I can change my code to prevent quotes for new documents, but I have existing signed documents that I can't download. How can I download them? Or fix them?
You will need to properly escape the quotes in your json.
The only way to know what is really happening is to see the api logs.
Added
To see the api logs, you have two choices:
See the instructions
Use the API Logging Feature of the new (still beta) Recipe tool. has a more convenient interface to the API Logger.
Using the current docusign_rest release (v0.3.1) I was able to create an envelope with a quote in the document's filename and then download that document:
client = DocusignRest::Client.new
res = client.create_envelope_from_document(email: {subject: "test email subject",body: "this is the email body and it's large!"}, signers: [{embedded: true, name: 'Joe Dimaggio', email: 'joe.dimaggio#example.org', role_name: 'Issuer',sign_here_tabs: [{anchor_string: 'sign here',anchor_x_offset: '-30',anchor_y_offset: '35'}]},], files: [{path: '/Users/tomcopeland/github.com/docusign_rest/test".pdf', name: 'test".pdf'},],status: 'sent')
client.get_document_from_envelope(envelope_id: res['envelopeId'], document_id: "1", local_save_path: "/tmp/foobar.pdf")
client.get_documents_from_envelope(envelope_id: res['envelopeId'])["envelopeDocuments"].map {|d| d["name"] }
=> ["test\".pdf", "Summary"]
Also, this latest release supports call logging so, if needed, you can extract logs client-side.
I'm trying to use next API method: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessages. Sending messages without attachments works just fine, but I can not understand how to send message with attachments.
According to docs, Message structure can contain array of Attachments with items of type https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesFileAttachment . Problem is in the field ContentBytes -- it is impossible to dump bytes to JSON before sending request to this API method (actually dumping any BLOB to JSON is nonsense).
How should I pass Attachments using REST API at all?
Thanks.
There's an example of passing the attachment on that page: https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#SendMessageOnTheFly
I know I'm 3 years late but, you can look at this example:
https://msdn.microsoft.com/office/office365/APi/mail-rest-operations#create-and-send-messages (if you don't get forwarded to the section "Create and send messages", please scroll manually).
I know it is 365 and not Microsoft Graph but request is absolutely same.
This is basically how JSON representation of the post method looks:
https://outlook.office.com/api/v2.0/me/sendmail
{
"Message":
{
"Subject": "Meet for lunch?",
"Body": {
"ContentType": "Text",
"Content": "The new cafeteria is open."
},
"ToRecipients": [
{
"EmailAddress": {
"Address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}
],
"Attachments": [
{
"#odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "menu.txt",
"ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
]
}
}