I've been trying to add a bot to my Telegram group in Android Device but I am not able to do so. I tried #bot_name, /bot_name, but it doesn't work.
Is it possible to add a bot to the group or should I create a new bot using Telegram API (not bot API) so that I can add the contact number to the group?
Edit: now there is yet an easier way to do this - when creating your group, just mention the full bot name (eg. #UniversalAgent1Bot) and it will list it as you type. Then you can just tap on it to add it.
Old answer:
Create a new group from the menu. Don't add any bots yet
Find the bot (for instance you can go to Contacts and search for it)
Tap to open
Tap the bot name on the top bar. Your page becomes like this:
Now, tap the triple ... and you will get the Add to Group button:
Now select your group and add the bot - and confirm the addition
You have to use #BotFather, send it command: /setjoingroups
There will be dialog like this:
YOU: /setjoingroups
BotFather: Choose a bot to change group membership
settings.
YOU: #YourBot
BotFather: 'Enable' - bot can be added to groups. 'Disable' - block
group invitations, the bot can't be added to groups. Current status
is: DISABLED
YOU: Enable
BotFather: Success! The new status is: ENABLED.
After this you will see button "Add to Group" in your bot's profile.
Another way :
change BOT_USER_NAME before use
https://telegram.me/BOT_USER_NAME?startgroup=true
In my case the 2 steps worked:
Added bot to a group as a regular member
Made Bot an admin.
The second step was needed to let Bot respond and sent messages to Group chat.
The response event.postData.contents looked like this:
{
"ok":true,
"result":{
"message_id":31,
"from":{
"id":1234567890,
"is_bot":true,
"first_name":"bot for custom alerts",
"username":"mybotname1_bot"
},
"chat":{
"id":-1234567890,
"title":"group name",
"type":"group",
"all_members_are_administrators":true
},
"date":1624860599,
"text":"hi"
}
}
I needed to receive the chat id (negative number from response) to send messages to the group by Bot.
Related
Heres the error message:
PS C:\Users\User\Documents\Discord Bot> node .
ready
C:\Users\User\Documents\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:154
throw new DiscordAPIError(request.path, data, request.method, res.status);
^
DiscordAPIError: Missing Access
at RequestHandler.execute (C:\Users\User\Documents\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
at processTicksAndRejections (node:internal/process/task_queues:93:5)
at async RequestHandler.push (C:\Users\User\Documents\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:39:14) {
method: 'post',
path: '/applications/723863781607997451/guilds/722043668730740788/commands',
code: 50001,
httpStatus: 403
}
Help is appreciated.
This is my first post on stackoverflow, so if I'm posting something wrong, please tell me!
This error is caused because your Discord Bot does not have permission to create commands for that server.
There is two ways to fix this.
Option 1 - In-App Authorization
You should first navigate to the Discord Developer Portal then you should click on the bot that you are getting the issue with.
You will then be prompted with this page:
You should then click on the "OAuth" page, highlighted in red on the above screenshot.
Once you are on this page, you should find the "Default Authorization Link" setting and set it to "In-App Authorization".
Once that option is selected another option will pop up asking what permissions the bot will ask the user for, you can see the screenshot below.
Select bot and application.commands then select the permissions that your bot requires.
Then save your changes.
You will need to re-authorize your bot to the guild before it will work, you do not need to kick it - just click on your bot and click "Add to Server" and re-add it to your guild.
Option 2 - URL Generation
You should first navigate to the Discord Developer Portal then you should click on the bot that you are getting the issue with.
Once you are on that page, you should access the OAuth sub-menu titled "URL Generation" as seen below.
Once you are on this page, you will be presented with a similar output to Option 1, you should configure the scope to be bot and application.commands and then request permissions as your bot needs.
Note
You should use both of these with your Discord bot, you should use Option 1 to setup your in-app authorization permissions and then use Option 2 to get a URL for Discord Bot lists, etc.
I am trying to create bot for MS Teams via Microsoft Bot Framework using some examples from the Internet.
I have created user card that has button "See Report"
function userCard(session, connector, name, workingStatus, TeamsID) {
var card = new builder.HeroCard(session)
.title(name)
.subtitle(workingStatus.toString())
.buttons([
builder.CardAction.dialogAction(session, 'userReport', TeamsID, 'See Report')
]);
return card;
}
Card is displayed without any issues. When I press on button it should trigger new dialog
//Begins the userReport dialog if the button on the userCard is pressed
bot.beginDialogAction('userReport', '/userReport');
This functionality works perfect when I test it in Bot Framework Emulator.
In MS Teams instead of triggering userReport dialog it goes to the main dialog (the one that is used when message is sent). So that this button does not work at all.
Could you, please, advise what should be adjusted/added in order to make this button work in MS Teams?
Thanks in advance!
Thank goodness you're just getting started. It looks like you're using Bot Framework V3, which is severely outdated. You should definitely switch to V4.
Teams has it's own additional trickiness. I recommend trying out and combing through each of these samples:
57.teams-conversation-bot
07.using-adaptive-cards
Then read through the Adaptive Cards blog post.
Basically, a response from an Adaptive Card comes back in activity.value, so in onTurn(), you'll want to use an if statement to watch activity.value for the value sent in your Adaptive Card when the user clicks "See Report". Then, use beginDialog or dialog.run(), as appropriate to start your dialog.
I'm using the Microsoft bot-framework to create a bot and integrate it into teams.
Part of the bot's requirements include proactively messaging users once per day. From what I understand, I can only message users that has been added to the team/groupChat after the bot, or that have messaged the bot directly.
My question is - can I somehow bypass this limitation?
A friend of my referred me to a new feature of graphAPI, as part of the new beta version - https://learn.microsoft.com/en-us/graph/api/user-add-teamsappinstallation?view=graph-rest-beta&tabs=http.
To me it doesn't seem like it could be related to the solution since I'm not getting any data back in the response, so if I have no conversationReference object I still can't message the user.
At the moment my solution is to simply broadcast a message in the channel when it's added, asking users to "register" with it by messaging it. Anyone has any other suggestion?
The easiest way is to:
Install the bot for the team
Query the Team Roster -- The link in Step 3 has an alternative way to do this towards the bottom
Create a conversation with the user and send a proactive message
There's a lot of code in those links and it's better to just visit them than to copy/paste it here.
The end of Step 3 also mentions trustServiceUrl, which you may find handy if you run into permissions/auth issues when trying to send a proactive message.
Edit for Node:
Install Necessary Packages
npm i -S npm install botbuilder-teams#4.0.0-beta1 botframework-connector
Note: The #<version> is important!
Prepare the Adapter
In index.js
const teams = require('botbuilder-teams');
adapter.use(new teams.TeamsMiddleware());
Get the Roster
// Get Team Roster
const credentials = new MicrosoftAppCredentials(process.env.MicrosoftAppId, process.env.MicrosoftAppPassword);
const connector = new ConnectorClient(credentials, { baseUri: context.activity.serviceUrl });
const roster = await connector.conversations.getConversationMembers(context.activity.conversation.id);
Send the Proactive Message
const { TeamsContext } = require('botbuilder-teams');
// Send Proactive Message
const teamsCtx = TeamsContext.from(context);
const parameters = {
members: [
roster[0] // Replace with appropriate user
],
channelData: {
tenant: {
id: teamsCtx.tenant.id
}
}
};
const conversationResource = await connector.conversations.createConversation(parameters);
const message = MessageFactory.text('This is a proactive message');
await connector.conversations.sendToConversation(conversationResource.id, message);
Trust the ServiceUrl, as Necessary
Read about it. You'd want this before the message is sent.
MicrosoftAppCredentials.trustServiceUrl(context.activity.serviceUrl);
EDIT: The Graph API you've referenced is only necessary if you wish to proactively message a user who is not in a channel/groupChat where the bot is installed. If you need to proactively message only people who are in context where the bot is installed already, the answer from mdrichardson is the easiest possible method.
We've identified a couple of issues with the Graph API beta endpoint you referenced that should be fixed in the near term. In the meantime workarounds are as follows:
Calling:
POST https://graph.microsoft.com/beta/me/teamwork/installedApps/
{"teamsapp#odata.bind":"https://graph.microsoft.com/beta/appcatalogs/teamsapps/APP-GUID"}
Will install an app in the personal scope of a user.
Known issue: Currently, if the app contains a bot, then installation will not lead to creation of thread between the bot and the user. However to ensure that any missing chat threads, get created, call:
GET https://graph.microsoft.com/beta/me/chats?$filter=installedApps/any(x:x/teamsApp/id eq 'APP-GUID')
Calling:
GET https://graph.microsoft.com/beta/me/chats?$filter=installedApps/any(x:x/teamsApp/id eq 'APP-GUID')
Gets the chat between a user and an app containing a bot.
Known issue: Calling this API will lead to sending a conversation update event to the bot even though there were no updates to the conversation. Your bot will essentially get two install events and you'll need to make sure you don't send the welcome message twice.
We'll also be adding more detailed documentation for the proactive messaging flow using these Graph APIs
I'm using Azure Bot Channels Registration for my bot, I have working endpoint and bot works well in Web Chat and My settings are:
Display Name: Engine Crave
Invocation Name: Engine Crave
Long Desc, Short Desc etc are all correct and filled and also organization at the last is also selected.
Also, My bot takes no user permissions. But when I save the Cortana Channel, I get a popup:
Unable to save.
There was an error saving the channel:
Failed to create bot module. Trace Id : 87140f58-46f8-4101-a849-17d63af6831c
Trace ID always keeps changing whenever I try.
Pls help!
Yayay! I found answer myself. Go-to settings and make display name same as your bot registration name when you registered on Azure! Mine was crave-engine.
Next goto Channels Registration -> Cortana -> Here you will see
Display Name: crave-engine
Invocation Name: crave-engine
Let these be like this and just click the "Register" button at the bottom. It's ok for now, You can however change these names When you register from https://knowledge.store .
I don't know these was some kind of bug or Azure Bot Team did this on purpose!
I have successfully hosted an instance of microsoft's Botframework web chat using directline on public domain, I want to make a chatbot in such a way that my customers can have their own channels completely separated from each other and I cannot find any kind of documentation anywhere, Kindly suggest me if this is possible and how?
I have written the complete code in Node.js and have very less idea about c#.
It seems that there is no such feature for uniform customized chat channel in bot framework. So we can leverage new builder.Message().address(address) to send messages to specific users from the official sample at https://github.com/Microsoft/BotBuilder-Samples/blob/master/Node/core-proactiveMessages/simpleSendMessage/index.js.
So I had a quick test which will save the users' addresses into an address list in server memory as a "customize channel", and trigger a key work to send message to these addresses in list as a broadcast in this "customize channel":
let channel_address = [];
bot.dialog('joinChannel',(session)=>{
channel_address.push(session.message.address);
}).triggerAction({
matches:/join/i
})
bot.dialog('broadcast',(session)=>{
channel_address.forEach((address)=>{
bot.send(
new builder.Message(session).address(address).text(session.message.text)
)
})
}).triggerAction({
matches:/^broadcast: .*/
})
Test Step:
Open two emulators connect to your local bot
in both emulators, type "join"
in either emulator, type text like broadcast: hi there