Error: Activity resulted into multiple skype activities bot FrameWork - node.js

I am trying to send an attachment using proactive messaging to a channel,
below is my code.
async function sendToChannelWithImage(message,channelId,img) {
MicrosoftAppCredentials.trustServiceUrl('');
var credentials = new MicrosoftAppCredentials('app-id', 'password');
var client = new ConnectorClient(credentials, { baseUri: 'https://smba.trafficmanager.net/us/' });
var conversationResponse = await client.conversations.createConversation({
bot: {
id: 'app-id',
name: 'test'
},
isGroup: true,
conversationType: "channel",
channelData: {
channel: { id: channelId }
},
activity: {
type: 'message',
text: message,
attachments: [img]
}
});
}
const img = {contentType: 'image/*',contentUrl: "https://theysaidso.com/img/qod/qod-inspire.jpg"};
message = 'test'
channelId = 'testid'
In this I am getting trying to send the message using bot framework,
what i have tried : https://learn.microsoft.com/en-us/azure/bot-service/nodejs/bot-builder-nodejs-send-receive-attachments

Sending a proactive message to a Teams team channel is no different from sending a proactive message to a personal conversation, so you should be using sendToConversation instead of createConversation. To send a proactive message anywhere, you'll need to make sure you have the conversation ID. In Teams, it's also important to trust the service URL.
If you want to start a new thread in a team channel, you can do that by removing the thread ID from the conversation ID. See here: Microsoft Bot - Node SDK: How to post to a public channel *without replying to a prev. activity*
It looks like there's a sample about starting new threads in team channels if you'd like to check that out: https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/javascript_nodejs/58.teams-start-new-thread-in-channel

Related

How to send message with viber bot to group chat?

Im trying to make a vibe bot that will only send announcements to group of people. The bot will not respond or interact with anyone, as its only and primary task is sending given text as an announcement to a group of people in the same chat.

I don’t understand:

a. What is wrong?
b. Why its not working?
c. Where to find the viber chat id?
d. Can I hook up this bot to any chat group (group/community/channel)?

const ViberBot = require('viber-bot').Bot;
const TextMessage = require('viber-bot').Message.Text;
const viberBot = new ViberBot({
authToken: process.env.VIBER_AUTH_TOKEN,
name: "...name...",
avatar: "...img-url..."
});
viberBot.sendMessage({ id: process.env.VIBER_GROUP_ID }, new TextMessage("hello world!"))
I triple-checked the auth tokens, and it's correct. But I still can't find the Viber Chat Id.
I tried to get the ending of a share link (to use it as the chat id), and the result I got was the following error:
{
status: 10,
status_message: 'webhookNotSet',
chat_hostname: 'SN-CHAT-16_'
}
{
status: 10,
status_message: 'webhookNotSet',
chat_hostname: 'SN-CHAT-20_'
}
{
status: 10,
status_message: 'webhookNotSet',
chat_hostname: 'SN-CHAT-10_'
}
Does anybody know how to fix this?

Cannot find documentation for botframework-connector functions examples

I'm using the botframework-connector npm package. And I want to use the sendOperationRequest & sendRequest methods from the ConnectorClient instance.
I have searched for the method examples here but can not find them.
Can anyone help me, please?
Edit:
I know how to use the create/update conversations via Conversations methods. I'm trying to scope whether I can use the package for other operations such as createChannel, add members to a group etc.
You should explore code samples in
https://github.com/microsoft/BotBuilder-Samples/tree/main/samples
rather than trying to understand how to use the SDK through the class references.
sendOperationRequest & sendRequest aren't really meant to be used explicitly, ConnectorClient uses it to send the request.
In order to send your message you first need a conversation reference (otherwise, how would the bot know which conversation to send the message to?) For example, look at the sample code on the documentation page of the NPM package you linked :
var { ConnectorClient, MicrosoftAppCredentials } = require('botframework-connector');
async function connectToSlack() {
var credentials = new MicrosoftAppCredentials('<your-app-id>', '<your-app-password>');
var botId = '<bot-id>';
var recipientId = '<user-id>';
var client = new ConnectorClient(credentials, { baseUri: 'https://slack.botframework.com' });
var conversationResponse = await client.conversations.createConversation({
bot: { id: botId },
members: [
{ id: recipientId }
],
isGroup: false
});
var activityResponse = await client.conversations.sendToConversation(conversationResponse.id, {
type: 'message',
from: { id: botId },
recipient: { id: recipientId },
text: 'This a message from Bot Connector Client (NodeJS)'
});
console.log('Sent reply with ActivityId:', activityResponse.id);
}
The botID and recipientID is dependent on the channel you use.
Edit : As I misunderstood the intent of the question.
If you want to create a channel, check out
https://github.com/howdyai/botkit/blob/main/packages/docs/core.md
There are officially supported channels with adapters that you can utilize. But if you are looking to connect to a custom app, look at https://github.com/howdyai/botkit/blob/main/packages/docs/reference/web.md#webadapter
for the generic web adapter that you can use to send and receive messages.

Proactive message using botkit on teams

I am trying to add new feature to the bot which is sending the message to some users proactively from the bot. am working on botkit ("botkit": "^0.7.4") and language nodeJS(node v10.24.1 (npm v6.14.12)).
Below is the code sample:
let bot = controller.spawn({"serviceUrl":"https://*****"});
params = { conversationType: 'personal',
tenantId: '66********',
id: 'a:1*********',
members: [
{
id: '29:1*********'
}
],
channelData: { tenant: { id: '6********' } },
is_group: false
}
bot.startConversationWithUser(params);
bot.say("hello");
Although it is not giving any error, but it is not sending the message. I checked all the documentation but fail to get any solution.
Can anyone suggest a way out where I am going wrong? Which is the right way to send proactive messages to the users on the teams?

How to send a private message to user on MSTeams?

I want to send a private message to user. Currently, what I have are:
user id
tenant id
bot
Here is my sample code to try to send message:
var address =
{
channelId: 'msteams',
user: { id: user.id },
channelData: {
tenant: {
id: "cscportal.onmicrosoft.com"
}
},
bot:
{
id: bot.id,
name: bot.name
},
serviceUrl: "https://smba.trafficmanager.net/amer-client-ss.msg/",
useAuth: true
}
var msg = new builder.Message().address(address);
msg.text("Hello! This is a sample message.");
msg.textLocale('en-US');
bot.send(msg);
My sample code does not work because of something wrong in my address. Can you help me to find a way to send a private message to user?
Note: I don't have conversation ID
You need the user’s unique ID and tenant ID to send a proactive message. Typically, these are obtained from a team context, either by fetching the team roster or when a user interacts with your bot in a channel. Please check documentation on how to create personal conversation. Please also read about Proactive Messages.
Here is the source code for Node.js sample for Proactive Messages.

Send slack message as any username

I'm trying to create a new integration to combine slack with another chat system.
If someone sends a message from skype for example, I want his name to be used when the message is sent to slack. Right now I'm using IncomingWebhook to send messages.
private getWebClient(configuration: ConfigurationData): IncomingWebhook {
return new IncomingWebhook('https://hooks.slack.com/services/...');
}
const webhook = this.getWebClient(configuration);
await webhook.send(
{
text: 'How are you today?',
as_user: false,
username: 'slack_integration',
icon_emoji: ':chart_with_upwards_trend:',
thread_ts: event.ts
}
);
As you can see, I'm also trying to reply to the message in a thread. This is not working either. The following event I get looks as follows:
{ text: 'How are you today?',
bot_id: 'B9G8LHME1',
type: 'message',
subtype: 'bot_message',
ts: '1519830326.000061',
channel: 'C9G4BJ8BW',
event_ts: '1519830326.000061' }
The message still appears to be from my App. The name is "Slack Integration Test" (with a badge showing App right next to it).

Resources