💬 Sending Activities
To send an activity you can either use the send
or reply
methods.
You can also stream
chunks of an activity.
Send
Example: a bot that listens for when a member is added to the conversation and sends a greeting.
app.on('conversationUpdate', async ({ activity, send }) => {
for (const account of activity.membersAdded || []) {
await send(`👋 welcome ${account.name}!`);
}
});
Reply
Example: an echo bot that listens for messages sent to it and responds.
app.on('message', async ({ activity, reply, send }) => {
await send({ type: 'typing' }); // send typing indicator...
await reply(`you said: "${activity.text}"`);
});
Streaming
app.on('message', async ({ activity, stream }) => {
stream.emit('hello');
stream.emit(', ');
stream.emit('world!');
// result message: "hello, world!"
});