Retrieving PSID from messaging_optins - node.js

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.

Related

Initiate message from bot in dialogflow

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.

How to replace default response in account linking on Google Assistant

As part of an action configured for account linking with the following topology:
Actions-on-Google->Dialogflow->Webhook,
I'm seeing Google Assistant injecting its own message prior to going through the account linking flow, as follows:
"I need to link your <action-name> to Google. Is that ok?"
The linking flow is triggered by the following in the webhook:
public ActionResponse launchRequestHandler(ActionRequest request) throws Exception {
ResponseBuilder responseBuilder = getResponseBuilder(request);
responseBuilder.add(new SignIn());
}
I'd like to be able to replace the above stock message with a custom one, however when attaching a context to a sign in card with our own message, like so:
String speech = "Hi, I see that your account isn't connected. "
+ "I've sent a link to your Google Assistant app that will get you started and set up in just several simple steps. "
+ "Don't worry, I'll be here waiting, just call me when you're ready.";
responseBuilder.add(
new SignIn()
.setContext(speech));
I'm still seeing the default message tacked at the end:
"Hi, I see that your account isn't connected.
I've sent a link to your Google Assistant app that will get you started and set up in just several simple steps.
Don't worry, I'll be here waiting, just call me when you're ready.,
I need to link your <action-name> to Google. Is that ok? "
How can I replace the Google default message with my own?
To ensure a consistent experience for users, you cannot replace the default message. You can only set the context, which lets you provide your custom information for the user ahead of the generic question.
The context is an additional piece of information which may be more relevant to your Action. Let's say it's connecting to your example.com account. You would add the context as a string:
app.intent('Login', conv => {
conv.ask(new SignIn('To provide you with personalized info from example.com'))
})
The user would hear this message, with the generic prompt appended:
To provide you with personalized info from example.com, I need to link your Example Action to Google. Is that ok?
Then you can say yes or no, and go through the OAuth flow / Google Sign-In flow.

Kik bot static keyboard does not appear

I was experimenting with a kik bot using Node.js, while I was trying to get a static keyboard to appear when user sends a 'help' message, it only sent the two replies and the static keyboard does not pop up. According to me it should work.
This is the function that sends the help messages:
/**
*
* #param {Message} message
*
*
*/
function help(message) {
message.reply('Hello!');
message.reply('Choose from the options to get an idea of what I can do! ;)');
message.addResponseKeyboard(['Rate me', 'Set reminder', 'Info']);
}
This is the bot configuration:
let bot = new Bot({
username: 'purppbot',
apiKey: 'dba843db-18bb-45fe-b6d6-3a678f420be2',
baseUrl: 'https://purppbot1-xbeastmode.c9users.io/',
staticKeyboard: new Bot.ResponseKeyboard(['Help', 'Info'])
});
I honestly don't know about Node.js; but as far as I see, I think you are expecting Static Keyboard to do what a Suggested Response Keyboard would do.
Regarding Static Keyboard, according to the API Reference of Kik docs, The static keyboard allows you to define a keyboard object that will be displayed when a user starts to mention your bot in a conversation, whilst regarding Suggested Response Keyboard, A suggested response keyboard presents a set of predefined options for the user.
It means the static keyboard is shown when a user starts to mention your bot in a conversation; and it disappears once a message is sent to the bot. And when the bot sends back a message to the user, it will contain its message(s) and Suggested Response Keyboard sent by the bot along with the message. In case no Suggested Response Keyboard is sent by the bot along with the message(s), the static keyboard is not shown until the user again starts to mention the bot's username.
So, in your case, you might want to send the those responses through Suggestive Responses Keyboard, which your bot would need to send along with the text message, every time a user sends the 'help' message.
I hope this helps.

Stacked Proactive Messages w/ Botframework

I'm trying to do the "Send a dialog-based proactive message" example on this page https://learn.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-proactive-messages … and have it resume with the dialog that was interrupted. The code doesn't work and then I noticed the note about botadapter.js. I tried to follow the "here" link but am getting a 401 error.
Is the code sample up-to-date because it looks like bot is expecting a function not an object for that 4th parameter.

fbsdkmessagedialog callback for iOS

I'm new to IOS programming, I'm trying to send message to Facebook friends using the below
[FBSDKMessageDialog showWithContent:content delegate:(id)self];
I have added callback as below:
- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
NSLog(#"complete");
}
- (void)sharerDidCancel:(id<FBSDKSharing>)sharer
{
NSLog(#"Cancelled")
}
But the sharer method is not called when I send a message in FB messenger rather the sharerDidCancel is called. The sharerDidCancel method is called when user cancels or send a message, how can I differentiate send vs cancel?
Facebook has a confirmed bug concerning this, however the addressed bug there is that it always calls sharer:didCompleteWithResults instead of sharerDidCancel.
Their next release contain a fix for this (v45) and hopefully this fixes our bug too (I'm having the same problem).

Resources