Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
Send the file

I would like to create a bot that sends "/data.csv" to a bot, attaches a data.csv file and replies. can you tell me.
I'm using SpringBoot BDK Java.

1
1
Posted 2 years ago
Edited 2 years ago
  
  

Can anyone please share an example of doing this in Python?

dk   2 years ago Report
Votes Newest

Answers


Sending and receiving messages is demonstrated numerous times in the BDK 2.0 courses. Please refer to the demos at the end of the chapters. Attachments are an optional field in the Message object, which accepts any type of InputStream. An example using FileInputStream would look like this:

// Java
Attachment file = new Attachment(new FileInputStream("./data.csv"), "data.csv");
Message msg = Message.builder().attachments(List.of(file)).content("Hello").build();
bdk.messages().send(streamId, msg);
# Python
with open("data.csv", "rb") as file:
  await bdk.messages().send_message(stream_id, Message(content="Hello", attachments=[file]))
1
1
Posted 2 years ago
Edited 2 years ago
Yong Sheng Tan
39 × 2 Administrator
1
1

An error occurs in FileInputStream. The following is the error content,
'Attachment (java.io.InputStream, java.lang.String)' in'com.symphony.bdk.core.service.message.model.Attachment'cannot be applied to'(java.io.FileInputStream)'

TN   2 years ago Report
  
  

Apologies - FileInputStream requires a second argument representing the displayed file name. I've revised the answer to reflect this.

Yong Sheng Tan   2 years ago Report
1
1

solved. thank you.

TN   2 years ago Report
  
  

@<1369010258210459648|dk> Added Python example above

Yong Sheng Tan   2 years ago Report
1
1

Thanks @Young Sheng Tan, I managed to get attachments to work with your example! Unfortuately the gif then the gif wasn't updating (refereshing for gifs) so I posted in this as an issue on github. https://github.com/finos/symphony-bdk-python/issues/262

Thanks to @symphony-youri for this one! Now the gifs should update!

with open("giphy.gif", "rb") as file, \
        open("giphy.gif", "rb") as filePreview:
    message = Message(content="<messageML>Hello, World!</messageML>",
                      attachments=[(file1, filePreview)])
    await message_service.send_message(stream...
dk   2 years ago Report
3K Views
1 Answer
2 years ago
2 years ago
Tags