Initiate message from bot in dialogflow - dialogflow-es

I want to get the welcome message from bot first in dialogflow. I am not sure how to do this. Any ideas on how to do this.
I tried reading about events in dialogflow as Default welcome intent uses "Welcome" event. But not able to find any solution.
As I opened up my bot framework, it should pop up "Hi, I am a virtual assistant. How can I help you?"

I am not sure of which bot technology you are using, but if your front end is in html/js, you may call a function like this:
Define it something like:
function myFunction(){
''here you may pass a parameter to your bot to display a pre-defined message. I am not going in details here, as I am not sure about the framework you are using.''
}
The onload (in body) will call myFunction(), everytime the page is refreshed.
P.s - I will update this answer once I get more details from your end. Since I am new here, please excuse in case of any issues.

Related

Can I send Hero cards to whats app by using Twilio

I have chat bot, I build it with bot framework nodejs SDK I integrate this chat bot to whatsapp and I want to display some buttons in the whatsapp chat,
So is there any one found a solution for this problem pleas help me
Note: I try to send a hero card but I run to problem
Error: TwilioWhatsAppAdapter.parseActivity():
An activity text or attachment with contentUrl must be specified.
I don't know how bot framework attempts to send WhatsApp messages with buttons, but I doubt it fits with the way Twilio wants to send them.
Currently, to send a message with buttons, you need to register and use a template message. When you send the text of a message that matches one of your templates, then Twilio will deliver the entire template with buttons as well.
For the future, look out for the Twilio Content API which will streamline templates, buttons and other rich messages across platforms.
It looks like you are using the TwilioWhatsAppAdapter from the botbuilder-community-js repo.
Looking at the adapter's code, it doesn't appear to be configured to handle any card other than a 'signin' card (see here). If you don't mind doing a little leg work on this, I don't see why you couldn't fork this repo and build in functionality that supports a hero card similar to the signin implementation.
I imagine it would look something like this:
case 'application/vnd.microsoft.card.hero':
// eslint-disable-next-line no-case-declarations
const hero = attachment.content;
message.body = `${ hero.text }\n\n`;
message.body += (hero.buttons[0].title ? `*${ hero.buttons[0].title }*\n` : '');
message.body += hero.buttons[0].value;
break;
The above may need a little massaging but it wouldn't be far off from this. Then, you just need to build the library for use.

How to remove the embed from specific messages and from messages coming from specific users/bots using Discord.js

I'm trying to code a bot that is able to remove the embed of specific messages or the embed created from the links posted by specific users and bots present in the server.
For example, let's say I don't want to see the twitter embed when someone posts a tweet: my bot would automatically remove the twitter embed.
Other case, I don't want people to see the embed of the messages posted by another user or bot present in the server, my bot would then automatically remove the said embeds.
However, reading the API documentation, I didn't see any possibility to do so. Maybe I missed it or maybe there's a trick to do so. Or maybe it's not supported by the API yet.
So does anyone know how I could achieve that goal please?
PS: Yes, I know I could simply deactivate embeds in the server settings, but that's not the goal I want to achieve here. I want it to be specific to certains links/messages and users/bots.
Thanks
You can use the suppressEmbeds method of message.
client.on("message", message => {
if (message.author.bot) return false;
if (message.author.id !== "YourID") { // Example Condition
message.suppressEmbeds(true) // Removes all embeds from the message.
}
})

Retrieving PSID from messaging_optins

I'm a new developer building a facebook messenger chatbot using node.js and Microsoft's BotFramework. I've got my chatbot up and running nicely and I'm now trying to personalise the welcome message with the user's first name.
I have a welcome message set up when a user clicks the "Get Started" button and I believe I should be able to retrieve the PSID using messaging_optins.
If so, I've got a a function that processes the Facebook payload in onEvent from the EventActivity.Value:
This cycles through some if/else statements to detect whether the Facebook payload is a Postback, Optin or Quick Reply:
If an Optin is detected it then prints "Optin message received" to the console:
The problem I'm finding is that my code isn't detecting the Optin message and so I'm not then able to write any code to extract the PSID to use to personalise my welcome message.
Can anyone point me in the right direction?
I’ve solved this as I found from the documentation here that it’s messaging_postback that are sent when 'Get Started' is clicked.

How can I delegate the LaunchRequest to an IntentRequest using the alexa-sdk from npm

I am building an Alexa skill in node using the alexa-sdk. I am using a dialog model to handle the user interaction. I am having some trouble passing the flow along to new request types, such as from the launch request to an intent request.
Below is an example of my handlers and what I want ideally. My specific usecase is that I would like to ask some questions of the user and then send them to different intents based on what they answer. In the intents I would like to have access to the request objects, as if they entered that intent originally, so the dialog model can do its work.
const handlers = {
'LaunchRequest': function () {
this.emit('Entry'); // this does not do what I want
},
'Entry': function () {
let request = this.event.request; // this is the launch request object.
// I would like to get the request object for Entry, like if the user started here
// ask some questions, potentially passing the torch to a new intent based on the answers
}
};
So, is there any way to "call" an intent like the user originally made a request to that intent? Sorry if I missed something obvious in the documentation, I searched around pretty thoroughly I think, but there is A LOT of documentation. ps: I could manually construct the request object of course, but I really should not have to I feel.
I am pretty sure there is no way yet to call on an intent as you are asking.
If you go through the syntax description of dialog directieves here, it says:
Note that you cannot change intents when returning a Dialog directive, so the intent name and set of slots must match the intent sent to your skill.
With returning a dialog directive you are able to 'elicit' or 'confirm' slots or intents, or even let a delegate handle your dialog for you, with prompts and reprompts set in the Skill Builder.
As far as i know, the only solution to trigger a specific intent is to make the user invoke it. You can guide the user into saying a specific utternace to trigger your intent.
As for saving older requests, you can use session attributes. Just build a response after your Launch with a session attribute containing the whole LaunchRequest.
"sessionAttributes": {
"oldRequest": this.event.request
}

Botframework LUIS Slack bot only reply when name is mentioned

I'm creating a bot in slack using Microsoft's botframework and LUIS and in Node.js. Currently my bot will reply every time someone says something in the channel, however I want my bot to only reply when its name is mentioned in my slack channel. i.e. #my-bot do this
How would I approach this? Would I have to add slack api in order to do this?
One way I'm thinking is to create an entity to check for if #my-bot is mentioned, and if it is then reply and if not then don't. However, I feel there are better ways in doing this.
Thanks.
Edit:
dialog.onDefault(function (session) {
var msg = new builder.Message(session).entities();
console.log(msg);
console.log(session);
session.endDialog('Default Dialog');
});
I've looked through both msg and session and the Entities of both are empty.
I was able to use session.message.entities to use mentioned to know whenever the bot was mentioned.

Resources