Hi Kunaal,
Here is another example using Java Spring Boot
public class EchoActivity {
@Autowired
private MessageService messageService;
@Autowired
private StreamService streamService;
@Slash("/echo {argument}")
public void echo(CommandContext context, String argument) {
V2StreamAttributes Stream = streamService.getStream(context.getStreamId());
log.info(Stream.toString());
this.messageService.send(context.getStreamId(), "Received argument: " + argument);
}
}
Hi Kunaal,
You can obtain information about a stream using the Stream Info endpoint.
Here is an example of how it can be used with the Python BDK
async def help_command(self, context: CommandContext):
room = await self.bdk.streams().get_stream(context.stream_id)
logging.debug(room)
return await self._messages.send_message(context.stream_id, "<messageML>Help command triggered</messageML>")
The returned results from the get_stream
call is shown below. One of the attributes returned is the room name,
2023-03-13 15:19:40,517 - root - DEBUG - {'active': True,
'cross_pod': True,
'id': '3MKJswHOSZGM_smkhuG2vn___nkkg9oTdA',
'last_message_date': 1678720779156,
'origin': 'EXTERNAL',
'room_attributes': {'name': 'My Room'},
'stream_type': {'type': 'ROOM'}}
Hope that helps.
Hi Kunaal,
Here is an example for Java. Note. the class names are usually similar between our Python and Java BDK's.
@Slf4j
public class Example {
public static final String STREAM_ID = "MY_STRING_UD";
public static void main(String[] args) throws Exception {
// Create BDK entry point
final SymphonyBdk bdk = new SymphonyBdk(loadFromClasspath("/config.yaml"));
// Get stream details
StreamService streams = bdk.streams();
V2StreamAttributes stream = streams.getStream(STREAM_ID);
log.info("Stream details: " + stream);
}
}