Is there a way to identify the "replied to" message with Messenger API - facebook-messenger

My Messenger bot asks a question:
"What is your favorite color ?"
My webhook receives a reply message:
"Red"
How can the webhook identify what was the question ?
Do I need to store something like the "lastQuestionSent" in the database ?

You could keep track of it in a session for that user. Maintaining sessions will pay dividends down the line.
You could include a reference to the question in your callback payload.

Related

Discord.js Animated Emojis

I have a bot, and I want to use it to send a animated emoji.
I have the emoji ID, <:rgb_lego:993606148580184154>
but whenever I make it send the message, it just says
Pong! 🏓 The round trip took 76ms. ⚡:rgb_lego:
what am I doing wrong?
It depends on what server (guild) you sent it and how exactly you do it.
Guess you need to check & fetch the requested custom emojie from server and then sent it.
You might wanna check Discord.js docs for that. But if I remember it correctly, emojies should be accessed by bot via:
client.guild.emojis.[methodName] via GuildEmojiManager
The second problem could be relevant to the server, where you want to sent it, doesn't have the required emojie, so in that case it has been delivered as a text ref, not an emojie itself or the bot account doesn't have premium features required for using emojies or so on.

How to mention a user mentioned in the command discord js

So im working on a discord bot, and working on a command where it mentions a user. For example: -fakekick #user and the bot would say User has been kicked I've read through the docs and found a few sites but I couldn't really understand it as I just started discord js a few days ago. Thanks
To get the user object of a mentioned user, you can very simply use the mentions extension of the message object. We can very simply use it in order to define our user, and later on, mention him in a future message. That can be done very simply as so:
const user = message.mentions.users.first(); // Would get the first mentioned user's object
message.channel.send(`${user} has been kicked!`); // To mention a user, you simply need to mention his user object.

Ask user for input from LaunchIntent

I'm writing a skill in Node JS 8. I have an intent set up with slots and it works properly if I say
Ask {skill name} to {utterance}.
I'd like to design my skill so that the user can just say
Open {skill Name}
and on opening it will ask them for input that will then be handled and passed to the intent. I've seen multiple people say that you can't do this. But I've used 2 skills today that did exactly this. I'm just looking for the correct syntax to do this.
I have:
'LaunchRequest': function() {
this.response.speak("What note would you like?");
this.emit(':responseReady');
}
Which seems like it should work, but I'm pretty new to JS and Alexa.
Yes, it is possible.
When the skill user open your skill, you can give a welcome message followed by a question.
Ex:
[user] : open note skill
[Alexa] : Welcome to note skill. What note would you like?
----------<Alexa will wait for users input>--------
[user] : ABC note.
[Alexa] : <response>
In order for Alexa to wait for users input after it says the welcome message, you need to keep the session alive. The session is kept alive based on shouldEndSession parameter in the response. For any request, if not provided, shouldEndSession defaults to true. In your case, the response to LaunchRequest should have this shouldEndSession parameter set to false. Only by which the session remains open and users can continue interaction.
Ex:
'LaunchRequest': function() {
const speech = "Welcome to note skill. What note would you like?";
const reprompt = "What note would you like?";
this.emit(':ask', speech, reprompt);
}
Read this answer to know more about how you can keep the session alive using ask-nodejs-sdk.
Using Dialog Model
Another way to achieve this is to use Dialog directives. Dialog directives helps you to fill and validate slot values easily. You can use the directives to ask the user for the information you need to fulfill their request.
More information on Dialog directives here

How to get Watson Assistant to capture multiple entities in context variables

I'm trying to create a Watson chatbot and I'm running into this issue.
I'm making chatbot that's helping people find organizations that provide food, shelter, drug treatment, etc.
I have a dialog node that asks the user what service they're looking for and storing it as a $service context variable.
This works well if the user says something like "I want food" as "food" gets stored into $service.
But say for instance a user says something like "I want food and drug treatment." I want Watson to then be able to store both of these variables as context variables.
How do I do that?
Its quite simple.
Just use
"service":<?#entityname.values?>
It will store all the input value of this entity in service array.

Alexa custom skill not giving answers to the default queries

I have created a custom skill for Alexa. I can able to get the response for custom skills also. But I'm getting one issue.
I have created a simple skill with invocation FullName and intent FullNameIntent which has the utterance like What is my full name, then it's returning my full name. But next query, if I'm asking what is the time now, it's giving answers again full name only.
My expected answer is current time as response.
You will have to create separate intent and sample utterances for 'what is the time now'. As you didn't mention anything about the intent for the time I believe you don't have an intent and sample utterance for the same.

Resources