how to get a welcome message in aws lex chat bot - amazon-web-services

I am creating a chatbot using amazon lex.
There is a use case for which I have to display a welcome message like 'Hello my name is LexC. How can i help you?'
How can I implement this? This message should be displayed without user type anything, so basically without invoking any intent.

Your Lex bot cannot display a "welcome" message without any prompts from the user. You would have to implement this functionality on the client side where the bot is integrated.
Since you mention that you're using the bot inside your web/mobile app, you can implement your own code to simply show a message to the user once your chat UI loads up in the app. For Slack however, you would have to look into their docs to see if something like that can be configured.

If you are trying it to do with Facebook Page, Then you can do this by following steps:
You can create a customized greeting from your Page that will appear in Facebook messages and in the Messenger app for iPhone, iPad and Android when someone begins a conversation with your Page for the first time. Your Page's greeting will appear before any messages are sent.
To create a Messenger greeting:
Click Settings at the top of your Page.
Click Messaging in the left column.
Next to Show a Messenger greeting, click to select On.
Click Change, edit the greeting, then click Save.

Related

Dialogflow CX | How to let the bot initiate the conversation?

Dialogflow ES has an event called 'WELCOME' which makes it possible for the bot to initiate the conversation.
How can I do the same in Dialogflow CX?
There is no entry fulfillment option in the Start Page of Dialogflow CX.
Edit:
Delete the 'Default Welcome Intent' route.
I am unable to perform this. I get the following error.
In 'Default Welcome Intent' change the intent from 'WELCOME' to nothing.
I get the following error. I have set the condition to true. I have also set the page transition to 'onboarding' page.
Please let me know if more screenshots are required.
To accomplish what you're asking, the easiest way would be to:
Open the "Default Start Flow" and select its Start page.
Remove all routes and add a new one.
This new route takes a "custom condition" in the form of true (in the condition pane, click on customize expression and then just type true) and goes to a new page
called "Onboarding" (on the bottom of the route creation page, click on new page and name it Onboarding).
Go to the Onboarding page and add an entry fulfilment "Hello there, how are you doing today?"
in this way every time the default start flow is activated (window is opened) the bot will use that fulfilment.
EDIT:
ok, i tried creating a new agent and i think i solved the problem.
it seems as though we can't erase the default welcome intent, but it doesn't matter.
i created two pages: onboarding and first page. from start i added an always true route to the onboarding page, and i did the same with the onboarding and first page. As you can see from the testing console we only get the expected behaviour for the second transition, look at this:
start page:
onboarding page:
"first" page:
After looking for info on the documentation i think i understood this: from the testing console, google doesn't let you see the actual behaviour of the conversation. If you see the screenshots, when i say "hi" and go the the onboarding page, i get immediately brought to the next page by that "true" transition. Since the same exact sequence is on the start page, the same behaviour should apply there: you only can't see it in the console because "opening the window" in the console is not the same as opening the conversation "in real life".
So, what i suggest you to do is create a new integration or develop a testing environment for the bot, say a website with the messenger integration, a telephony integration or whatever else, and test this onboarding on there. Speaking from personal experience, try with the messenger one maybe: you get a link and you just embed the script in any webpage (works well and easy).
It should work, as in, as soon as you open the conversation, the bot should go the onboarding page and say "hello there!"
So, I'm not sure what your end use-case is, but DFCX (at it's core) isn't exactly designed to initiate an unsolicited message because it's really just a language model with a bunch of features built on top of it.
With that being said, if you want to create a pop-up window for your website chat-widget, you can actually configure this in the integration settings with your embed code. Here's an example:
//The DF Messenger element:
<df-messenger df-cx="true" chat-title="Agent Name" agent-id="<your agent ID>" language-code="en" expand="true"></df-messenger>
//The window load script :
<script src="https://www.gstatic.com/dialogflow-console/fast/messenger-cx/bootstrap.js?v=1"></script><script>
window.addEventListener('dfMessengerLoaded', function (event) {
const dfMessenger = document.querySelector('df-messenger');
const openText = ('<The Text You Want To Display On Page Load>');
dfMessenger.renderCustomText(openText);
});
</script>
Please note this will only work if you have the DF Messenger Integration enabled on your agent. See the docs for integrating DF Messenger here
1.Use the attribute intent inside the df-messenger tag in your UI/HTML page
2.Then create a Custom Event in Dialogflow CX (By clicking on Event handler '+' icon)
3.Check the 'use custom event' checkbox and provide event name and provide a text response in fulfillment section of this custom event.
4.Finally provide this custom event name as value to the attribute intent(mentioned in step 1)
please refer to this document for df-messenger HTML customizations https://cloud.google.com/dialogflow/cx/docs/concept/integration/dialogflow-messenger#html-customize
According to Dialogflow CX documentation, the WELCOME event (although not visible in the Start flow) is also available. As you can see in this link and the picture below.
To invoke this event, you have to use the detectIntent method of a Session client. You'll need to specify the event name in queryInput.event.event of the request used in detectIntent.
Hope this helps!

Is there anyway to initiate chat in dialogflow?

I am working in Dialogflow right now, is there any way to initiate chat using webhooks instead of using the common welcome massages given by dialogflow or some chat apps. Like I want to have my own initialize chats for many different situations. For example, today is my day to save money, then it will initiate a chat to make sure user get into save_money_daily intent. More details on the comment
There are few things that you wanted to do here that are not natural, I guess. Let me go on each:
How can I send an automatic chat for every possible case from the backend automatically?
Ans: You are building a google assistant on dialog flow, using as a chatbot, any chatbot can not send an automatic message(unless set by user), chatbots, and assistants are in the nature of the user interaction.
Let's any bot on Facebook, Skype, or any platform even the google assistant, they can't popup unwantedly with any information, it will be not user friendly.
There is a way to do, like if the user is interacting with your bot: You can ask like:
'Do you want me to remind you for saving money every day'
If user gives permission, save it in-app local cache and send app notification, via. Once the user get the app notification you can invoke the chat on the app notification click and open chat screen with your reply, but in the background when the user clicks on app notification you have to send a request to initiate chat.
And this solves your second problem as well.
Let me give you a high-level example:
Three Intent: With some user utterance
GetLatestMoive: ['get me the latest moives list']
GetLatestNews: ['Headline for today']
HealthCheck: ['I want health tips']
Create Notification and send it to the user via the app:
Based on the notification if the user clicks any of them, initiate your chat in-app with that utterance, it will automatically call the intent, and rest will follow based on your intent follow up a map and conversation design.
Hope this helps!

How to set welcome message for messanger chat bot build using AWS Lex

I built a chat bot for my project using AWS Lex and then I integrated it with Facebook Messenger. After integrating with Facebook Messenger my chatbot interface looked like this.
In the image you can see when some open the messenger he will get suggestions like "Where are you located?" or "What are your hours?" etc. by default.
Expected output: I want instead of these default suggestions messenger should display customized message like "Hello welcome".
You can create a customized greeting from your Page that will appear in Facebook messages and in the Messenger app for iPhone, iPad and Android when someone begins a conversation with your Page for the first time. Your Page's greeting will appear before any messages are sent.
To create a Messenger greeting:
Click Settings at the top of your Page.
Click Messaging in the left column.
Next to Show a Messenger greeting, click to select On.
Click Change, edit the greeting, then click Save.

OAuth2 Signin from a Bot, based on Enterprise Bot template(v4 SDK), does not work with MS Teams desktop app

I have a bot which is based on enterprise bot template(Bot builder framework SDK v4.0). I have called AuthenticationDialog (OAuth2 sign-in with AAD v2) as per other thread in the stack overflow, i have implemented to handle Invoke Activity with "signin/verifyState" in my IBot implementation , it works fine on Microsoft Teams Web app, however, MS Teams desktop app puts up the dialog for selecting sign-in user, immediately, it closes the dialog and sends the Invoke activity with signin/verifyState with "{ "state": "123456"} , i am displaying user to enter the state, when user enters, it works.
Is it a bug in the Desktop MS Teams app
(or) I am doing something wrong.
From my bot, I don't use the following line which is in the SDK sample:
await Dialog.RunAsync(turnContext, conversationState.CreateProperty<DialogState>(nameof(DialogState)), cancellationToken)
In Slack same code works like this, bot puts up the sign-in dialog, when user clicks on Sign-In, browser display the sign-in option where user can select specific user name account, after successful login, it display the screen with:
Please enter this validation code into the chat window to complete the sign-in:
123456
When user enters the code, automatically TokenResponse is given to the bot.
In TeamsAuth sample, Startup.cs calls
// Create the bot as a transient.
services.AddTransient<IBot, TeamsBot<MainDialog>>();
In my bot calls
services.AddBot<>()
any idea how it can be done on my case?
I have it working well with OAuthPrompt & Azure Bot Service in both Teams desktop and mobile.
Here is my code for your reference. Check it out and see whether similar code works for you.
BTW The new suggested way of adding bot is to register it using services.AddTransient<IBot, TBot>(). Try to avoid using AddBot.

Trigger User Action from Facebook Messenger Bot

I have a working Facebook messenger bot.
From the Messenger app, I would like my bot to trigger the "camera" action (to snap a new picture or video) for the user.
To clarify with a hypothetical context, I would create persistent menu action which mimics the behavior of clicking the "camera" button under the message text area.
I looked into the "Page Call To Action" operation of the Graph Api but could not find parameters that would produce the desired behavior.
Here is the solution to your problem.
In Facebook Messenger, you can open a webview and load a webpage. But remeber that good old HTML 5 provides us with a simple way of asking the user to use their camera when they are on mobile.
These steps below work today
You can use a url button to open a webview as such
"buttons":[
{
"type":"web_url",
"url":"https://url_to_your_webpage",
"title":"View Item",
"webview_height_ratio": "compact"
}
]
In your webpage, include this HTML5 element that allows user to take image via camera on mobile
<input type="file" accept="image/*" capture="camera" />
Submit the image to your servers, close the webview, and do any processing required. For example you can now send the image back to the user from your bot.
I'm pretty sure there is no way to do what you want, right now. Hopefully, in the future, the Messenger team will add more features like this to bots.
You can simply send a message to the user to click on the camera icon, click the picture and send it to the bot. You can then receive that image as the attachment -> read 'Message with image attachment' and reply to the user. This will be more of the native experience. In webview the user can deny permission to the camera (if asked for). Hope this helps!