I am trying to send personal message to particular user using webhook. I created webhook so i am getting personal message. But I am not able to send personal message to others personal chat. I don't want to use bot.
slack.setWebhook("Webhook");
slack.webhook({
channel: "D01KMUZ4E4S",
username: "webhookbot",
text: "This is posted to #general and comes from a bot named webhookbot."
}, function(err, response) {
console.log(response);
});
Slack Webhook URLs are tied to a particular channel, individual message, or group message. You need to create a new webhook in your workspace for each user you would like to send messages to.
Related
guys! I have a task to create AWS lambda endpoint for resetting user's password. I have to send a new password to user's email. I have read a lot about SNS and SES and currently have no idea what service is better for my purpose. Will be glad to hear from you advice!
Here is my lambda code
const requestData = AdminResetPasswordDto.from(event.body);
const errors = await AdminResetPasswordDto.validate(requestData);
if (errors) {
return new BadRequestError({ message: "errors.invalid-request-params", errors })
}
const repo = new UsersRepo();
const entity = await repo.getOneByEmail(requestData.email);
if (!entity) {
return new BadRequestError({ message: 'errors.user-not-exists' })
}
// const newPass = generatePassword();
// sending newPass to user via SNS
// use SNS or SES ???
// https://docs.aws.amazon.com/sns/latest/dg/sns-email-notifications.html
const user = UserDto.fromEntity(entity);
const result = await repo.updateUserPassword(user.userId, user.userRole, newPass);
if (!result) {
return new BadRequestError({ message: 'errors.password-not-updated' })
}
return new ResponseSuccessNoBody();
SES is meant for sending high-volume e-mail efficiently and securely. Once you have verified that you are the owner of an e-mail address, you can send e-mails through SES to any other e-mail address without the recipient's consent. SES takes care of the engineering required to ensure the delivery of their e-mails.
SNS is meant as a channel publisher/subscriber service. In order to receive e-mails from SNS, the end-user must first subscribe and approve that subscription through e-mail before amazon delivers e-mails from the subscribed channel to that end-user. End-users can subscribe via e-mail, SMS, webhooks, and other means up to the user independent of the publisher.
On a practical level, we use SES to send our users e-mails about their content and we use SNS to send our developers notifications (via SMS and e-mail) when servers go down or have issues.
In short,
SNS
email messages
SMS
push notifications to mobile device
messages between services/apps
Clients have to subscribe, to receive above notifications
SES
email messages
No subscriptions required
SNS is used for “technical” notifications; delivery as e-mail is possible, but rather limited. First, you need to create dedicated subscriptions and provide the destination mail address at this point. Second, you can’t really “design” your messages, it will just be a blob of text. You should go with SES for messages where the recipient is determined at runtime and you want to have control over the message layout.
I'm creating a bot to notify a user after an action has been done. Where i'm able to get my details using the below(screenshot) code.
Now in order to send a message to a user through a bot i would need his/her ID before hand to send a notification like in the above case i'm able to extract my info as i'm already logged in Teams. Unfortunately alphanumeric ID is very difficult to use and needs to be there before requesting and sending the notification.
Below is the JSON result if the ID is already known.
Response body
{
"id": "29:1GcS4EyB_oSI8A88XmWBN7NJFyMqe3QGnJdgLfFGkJnVelzRGos0bPbpsfJjcbAD22bmKc4GMbrY2g4JDrrA8vM06X1-cHHle4zOE6U4ttcc",
"objectId": "9d3e08f9-a7ae-43aa-a4d3-de3f319a8a9c",
"givenName": "Larry",
"surname": "Brown",
"email": "Larry.Brown#fabrikam.com",
"userPrincipalName": "labrown#fabrikam.com",
"tenantId":"72f988bf-86f1-41af-91ab-2d7cd011db47",
"userRole":"user"
}
How i can get the unique ID of the user by using email id so that i can send a personal message to him/her using bot.
There is an option to fetch conversationChatId to send proactive message.
Before you fetch the conversation Id, you should check whether your bot is currently installed for a message recipient or not.
Note: Installation of app via Graph API triggers conversation update event for Bot.
I am using a web service api to receive message from a slack channel (event subscription) and the same web service api to send message (Incoming webhook) to the user on the same slack channel.
But when I send a message, this same message is send back to my api by the slack event subscription. That create an infinite loop.
How can I declare my message that I am sending to the channel which I can check when I receive back by the event subscription ?
This is normal behavior of Slack and can not be changed by any configuration. When you subscribe to message events you will receive events for all messages, including the ones from your own app.
To avoid an infinite loop you therefore need to detect and filter out the messages from your own bot before continue processing. This can be done easily, since all messages contain the name of the the sender. e.g. you can filter out all messages that are have the bot_id of your Slack app or all messages from bots (that have subtype = bot_message).
Here are some examples how messages look like and how messages from real users are different then message from Slack apps:
Example message from a real user:
{
"type": "message",
"user": "U12345467",
"text": "Good read for some of guys",
"ts": "1531745292.000021"
}
Example message from a Slack app or bot
{
"text": "Hey guys",
"bot_id": "B12345678",
"type": "message",
"subtype": "bot_message",
"ts": "1531700187.000049"
}
See also this answer.
How do we mention the conversation id in the botframework webchat instead of it being randomly generated? We can currently mention the userid and username for the webchat but could not have the conversation id mentioned.
For more information on this subject, check out the guide: Send proactive messages.
To be able to send an ad hoc message to a user, the bot must first collect and save information about the user from the current conversation. The address property of the message includes all of the information that the bot will need to send an ad hoc message to the user later.
bot.dialog('/', function(session, args) {
var savedAddress = session.message.address;
// (Save this information somewhere that it can be accessed later, such as in a database.)
var message = 'Hello user, good to meet you! I now know your address and can send you notifications in the future.';
session.send(message);
});
After the bot has collected information about the user, it can send an ad hoc proactive message to the user at any time. To do so, it simply retrieves the user data that it stored previously, constructs the message, and sends it.
function sendProactiveMessage(address) {
var msg = new builder.Message().address(address);
msg.text('Hello, this is a notification');
msg.textLocale('en-US');
bot.send(msg);
}
Clarifying my post:
I'm setting up a facebook chatbot using the sample code. This should allow me to send messages to the chatbot (via Messenger iOS app, or via chat window at Facebook.com, app page). The expected behavior would be
Send chat message
Echo chat message
Display correct logging, no errors
However, when I send a chat message, while it correctly echoes the chat message, I am finding an error in my logging. It produces the following error message:
{ message: '(#100) No matching user found',
type: 'OAuthException',
code: 100,
fbtrace_id: 'D+PAc3ZfmLS' }
After investigation, it appears as though the app is identifying the incorrect userID for my account (app owner). It has the correct receiver ID (page ID of the application). I cannot figure out why this occurs. A copy of typical logging information is below. The incorrect sender ID is listed as "1053426944750274".
Received message for user 1053426944750274 and page 289085874757891 at 2016-07-06T20:32:31+00:00 with message: {"mid":"mid.1467837151667:954f158fd950334f60", "seq":212, "text":"marco"}
Successfully sent generic message with id mid.1467837152021:729cf052bc826dc592 to recipient 1053426944750274
Received message for user 289085874757891 and page 1053426944750274 at 2016-07-06T20:32:32+00:00 with message: {"is_echo":true,"app_id":284007785268790, "mid":"mid.1467837152021:729cf052bc826dc592", "seq":213, "text":"marco"}
Are you sure you are using the sender.id in the message recipient.id?
be aware that Facebook id is different than what you need to use when you respond to users via messenger send API.
When representing a user, these IDs are page-scoped IDs (PSID). This means that the IDs of users are unique for a given page.
If you have an existing Facebook Login integration, user IDs are app-scoped and will not work with the Messenger platform.
source