Facebook Messenger bot: 1st interaction different to subsequent for same command? - facebook-messenger

Does anyone know if it's possible to return a different message etc to the chat user if it's the very first time they are interacting with the bot?
For instance, if a user says "hello" (or anything) for the very first time, the bot might respond with, "Hello there!"
If a user says hello some time later, the bot might respond with "Hello, again!"
Looking through the developer docs I'm struggling to find an answer: https://developers.facebook.com/docs/messenger-platform
For context, I'm also using the https://api.ai service.

One way to accomplish this is to set up a "get started" button:
https://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button
This might also be helpful:
https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text
(But I haven't used it myself, so I'm not sure what it does.)
Also, as already mentioned, you can store user data in your own database, and send a greeting message if you can't find the user there already.

This would currently not be possible with API.ai out of the box, you'd have to build a custom webhook that would save the user id to database and check it on new session.
As a (very) hacky workaround you could try outputting a context after the first hello and each and every other intent you use inputs and outputs that context, essentially remembering the user has talked to the bot via a 'permanent' context.

Related

Automatically send messages as current user in discord

I'm new to discord.js but I would like to understand. Is it possible to achieve a functionality that would send message as my current user?
I mean for example I'm normal user on a discord server and I want to send randomly some jokes every day once. But this should happen from my current user, which has the discord name.
I know I can have a bot created and registered, but this is another approach I think.
My questions are: Is this achievable with discord.js or not really? Is this functionality achiavable at all? And where do I begin?
Thanks for any help.
It is possible. It's just like making a discord BOT. But rather than making a bot application and using its token, you just use YOUR token.
This is purely for educational purposes only, and you shouldn't use it for anything else. Everything is possible, especially with discord.js.
What you are describing is a "self-bot", and is against the Terms of Service. As such, it is not supported.
Discord has made an announcement regarding self-bots before.
Here is a relevant excerpt:
Automating normal user accounts (generally called "self-bots") outside
of the OAuth2/bot API is forbidden, and can result in an account
termination if found.

Discord.js embeds not showing users correctly

EDIT: Apparently it's a client-side issue so not really an issue with the code
I have an application system but the user name/tag doesn't show up right sometimes
is there any way I could fix this or is it a discord issue?
It only works with some members plus it makes it a bit inconvenient to find the user that submitted the application
Sometimes it looks like this (which is wrong)
and sometimes it looks like this
I would do something like
// Create our application, we will fill it later
const application = new MessageEmbed()
.setTitle("New Application")
.setDescription(`This application was submitted by ${member}/${member.user.tag}`)
.setColor("#ED4245");
but that feels like something very stupid to do and probably would get killed by someone who has more knowledge than me with bots 😂
TL;DR : Using approach you thought of is absolutely fine and this only happens when a user isn't available to the guild or hasn't occured to the individual seeing the channel before
Usually if the user hasn't been seen before ( condition like channel access and unavailable to that guild may also apply ) by the individual viewing the channel the ID may show as is like in your case, that is due to discord maintaining only users ever seen by the individual ( this is client side not from Discord itself) to overcome this you may just add the username of the individual at the top of the application
<member>.user.tag
As you answered yourselves! Not to worry though! That's what a smart developer would think of!
Please make sure that if the user has a nickname it's a better approach to use <#!userID>, explained here in <#userID> vs. <#!userID>, discord.js auto-parses that mention for you so in your case it's probably just one of the cases I mentioned above for which the user remains uncached at client side.
You can get the discord user id and tag the user by using
<#insert user id here>

Salesforce Chatbot : use NLP when the bot ask Question

I have setup a chatbot for my customer.
For that, I have configured the bot with different dialogs and pattern to help them going to the response they seek. I also have activated the Einstein bot intent (Natural Language Processing : NLP) to let them type answer to get directly to the right dialogs.
But it's here that I have a problem. When I set a dialog with a question (with or without choices) when I write an NPL answer, the bot stop and wait another input.
Exemple: the bot asks "Are you ok?" if I respond "Agent" (word link to another dialog) the bot stop and if I rewrite "Agent" the bot start the dialogs "Agent".
Dialog config : Dialog config
Chat exemple : Chat exemple
I don't know why it's happening or how can I resolve this. I have read the documentation but nothing link to this problem.
Thanks for your time
I have found the issues. It comes from the entity that we were using. The entity was set with a standard text. So, when a user was writing some text (utterance values or not) it was store and that was good for the bot.
The solution was to create an entity of Value type. Write in it the Buttons label. Like this if a user clicks on the button or write the button label, it can be stored and go further, if not it will go on the intent recognition. And finally, if all the 2 fails, the bot goes in the conversation repair.
Here is a process Schema draw by a salesforce member

How send notification into ms teams user from custom tab

I'm designing a custom team tab using React that calls third party API, I need after executing the API successfully, user gets notified . What is the best way to achieve this? I used Bot in my project, but not sure how can I call it from my custom tab class. I'm aware of the existence of proactive messaging, is it the only way to do it? If it is, a pointer on how to implement it to a custom tab would be appreciated.
If you're wanting to message the user 1-1 (like in the personal app), then proactive messaging is definitely what you need (inside a Team, there are other options), and considering you have the bot already in place that's perfect. The only thing you might be missing are the details required to send the actual proactive message (the best time to get them is when the bot is first installed by the user). In particular, you need ConversationId and ServiceUrl.
With regards the concept of Proactive Messaging, basically once the bot is installed, and you have the required values, you can -send- the message from any backend code at all. That can include, for example, custom tab's backend api. You need to identify the user, which you can do using the Teams Context (it's not the safest way but it's the easiest), and then look up the values in your own backend store (e.g. database or whatever) to get the ConversationId and ServiceUrl, then just message the user in your backend.

Facebook Messenger: Is it Possible to Initiate Chat With Parameters?

Back in the day Facebook used to let you define URLs that were something like http://facebook.com/send_a_message/user/55/pre_fill/Hi there. When you clicked that link Facebook would open up its Messenger with a "Hi there" message ready to be sent to user 55.
But then Facebook decided that "pre-filling" was bad, and outlawed it across all their APIs. Now there are a bunch of different ways to initiate a Messenger chat session, but they all amount to "start a chat with user 55", not "start a chat with user 55 using some information".
The thing is, I'd like to somehow pass information along with the link. For instance, I might want to have three different links on three different pages, and I want my chatbot to be able to respond differently based on which page the user came from. Since I can't "pre-fill" a message (eg. "Hello, I just came from page A"), I'm wondering if there is any other way to pass auxiliary information.
TLDR
I'm wondering if there's any way I can possibly provide a user with a link that, when they click it, starts up a chat session with my chatbot user, and somehow passes information to it. Using an intermediate proxy (ie. having the link go to my server, and then have my server start the chat somehow) would work, but only if I can associate the information with the user (ie. it doesn't help to know "page A" if I can't associate that with the user once they start chatting).
After researching further it would appear that the answer to my question is no: there is currently no way to pass-along supplemental information.
But here's the good news: when I filed a bug about this (which it turns out I should have filed as a feature request, sorry Facebook) I got a response saying something to the effect of "we couldn't tell you that we are currently developing this, even if we were", which I'm going to optimistically choose to interpret as a sign hope means that this functionality may be coming in the future.

Resources