botframework - Bot send dynamically created, downloadable CSV using Microsoft Bot Framework (C#) -


goal: dynamically create csv file information sql server query (don't want save file) , send user in bot response on slack. user clicks on link download file computer.

i have created file information in memorystream, having trouble sending in bot response. c# pseudocode , code inspired this:

public async task useselectedupc(idialogcontext context, iawaitable<object> item)     {         var upc = await item;          // use upc query sql server , obtain information         // use information create memorystream result in format of csv file          reply.attachments = new list<attachment>()                 {                     new attachment()                     {                         contenttype = "text/csv",                         content = $"data:text/csv; base 64, {convert.tobase64string(result.toarray())}",                         name = "sample.csv"                     }                 };         reply.text = "results: ";         await context.postasync(reply);     } 

i've tried

content = result, 

and

content = result.toarray(), 

and

content = "hello", 

and

content = convert.tobase64string(result.toarray()), 

i tried changing contenttype , name "text/plain".

but see in bot framework channel emulator [file of type 'text/csv'] , no link. in slack, nothing appears besides attachment's text.

the microsoft bot framework attachment class vague acceptable content. what attachment content acceptable , how can translate memorystream result acceptable format?

to use slack-specific message functionality, need configure json object containing attachments, , place in channeldata property of activity object.

from article implement channel-specific functionality > create full-fidelity slack message

to create full-fidelity slack message, set activity object's channeldata property json object specifies slack messages, slack attachments, and/or slack buttons.

this snippet shows example of channeldata property custom slack message.

"channeldata": {    "text": "now in stock! :tada:",    "attachments": [         {             "title": "the further adventures of slackbot",             "author_name": "stanford s. strickland",             "author_icon": "https://api.slack.com/img/api/homepage_custom_integrations-2x.png",             "image_url": "http://i.imgur.com/ojkavoi.jpg?1"         },         {             "fields": [                 {                     "title": "volume",                     "value": "1",                     "short": true                 },                 {                     "title": "issue",                     "value": "3",                     "short": true                 }             ]         },         {             "title": "synopsis",             "text": "after @episod pushed exciting changes devious new branch in issue 1, slackbot notifies @don unexpected deploy..."         },         {             "fallback": "would recommend customers?",             "title": "would recommend customers?",             "callback_id": "comic_1234_xyz",             "color": "#3aa3e3",             "attachment_type": "default",             "actions": [                 {                     "name": "recommend",                     "text": "recommend",                     "type": "button",                     "value": "recommend"                 },                 {                     "name": "no",                     "text": "no",                     "type": "button",                     "value": "bad"                 }             ]         }     ] } 

for more specifics on slack attachment json structure, see: https://api.slack.com/docs/message-attachments


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -