How to integrate AWS Lex Chatbots Voice to Facebook - amazon-web-services

I had configured my chatbot using AWS Lex Chatbot service. My main intention to create chatbot is to integrate it to Facebook and the user's communication should possible in both text and voice. I integrated my chatbot to facebook successfully by following steps give in AWS documentation. BUt voice piece was not working on facebook. Please, provide me any suggestions or any reference blogs of integrating lex voice piece to Facebook along with the text.

Facebook Messenger doesn't interpret lex responses into Voice responses, at least not yet.
The event object received, when accessing Lex from Facebook, will generate requestAttributes and those specify the accepted content types under x-amz-lex:accept-content-types.
"requestAttributes": {
"x-amz-lex:accept-content-types": "PlainText"
},
As you can see, PlainText is the only accepted content-type. Even though Lex has 4 supported message content-types: 'PlainText', 'SSML', 'CustomPayload', and 'Composite'. See here.
From Facebook Messenger Docs:
The Messenger Platform allows you to attach assets to messages, including audio, video, images, and files.
Even though Facebook accepts attachments of audio, Lex only sends PlainText or SSML.
Lex does use Facebook's messsage attachments when it sends Response Cards, but the Response Cards can only have a Generic Type, so that it only sends images, not audio files. See here.

Related

Dialogflow set speech response as default auto response

I'm trying to set the response that answers the questions posed to dialogflow to automatically be spoken/set to speech as a default in web-chat.
What I mean is, when the user asks a question, I want the bot to automatically return with a speech response so that the user doesn't have to click the "speack" button on the message.
I'm using a C# API webhook to set the responses to the questions.
Thank you.
You cannot set the Dialogflow generated Audio as the default response. It depends on how the platform, in this case the web-chat, decides to handle the information retrieved by Dialogflow. If you have control over the web-chat code, then you can request Dialogflow to return an audio by sending the outputAudioConfig parameter in the DerectIntentRequest, and then have the web-chat code to play the audio.
If you don't have control over the web-chat, then you'll need to know how they're processing the Dialogflow's response so you can adapt your responses.

Is it possible to send and fetch Facebook messages using Graph API for v4.0 or greater?

I want to create a web application using PHP which will allow to connect Facebook accounts with my application and once they authenticated my application can fetch inbox messages of that user and can auto reply to the messages received against authenticated Facebook accounts.
Also, allow user to send messages manually from my application to Facebook inbox.
Is this possible with Graph API or any other Facebook API which will allow me to do above mentioned things.
Some people was told that this feature is no longer available after Facebook Graph API v2.4.
and once they authenticated my application can fetch inbox messages of that user and can auto reply to the messages received against authenticated Facebook accounts.
Neither of those two things is possible.
You can not read the messages of user accounts any more, and you can not reply in their name either.
The only messaging that can be handled via API, is that between a user and a page.
Assuming you refer to Page conversations, not user conversation, see /conversations and /messages docs here:
https://developers.facebook.com/docs/graph-api/reference/page/conversations/
https://developers.facebook.com/docs/graph-api/reference/v5.0/conversation/messages

Does Amazon aws lex chatbot supports videos?

I am new to Amazon aws, Is lex chat bot support video eg MP4 , ?
Assume something like this:
Bot: would you like to watch the tutorial?
Human: Yes.
Bot: displays a video
A video can be alone or with response card .
Is this possible????
You can define a custom payload as a response from a Lex bot (using a Lambda function for the fulfillment), but you would also have to integrate the Lex bot into an application that could appropriately handle that response (display the video based on the response from the Lex fulfillment lambda).
The supported message formats are:
PlainText—The message contains plain UTF-8 text.
SSML—The message contains text formatted for voice output.
CustomPayload—The message contains a custom format that you have created for your client. You can define the payload to meet the needs of your application.
Composite—The message is a collection of messages, one from each message group. For more information about message groups, see Message Groups.
Moere info on Lex messaging and the CustomPayload here: https://docs.aws.amazon.com/lex/latest/dg/howitworks-manage-prompts.html
So the answer is that it is possible, but not a built in functionality.
Amazon lex will be able to send whatever response is required, it's the job of chat client to render that response and displays accordingly.
There will be a different way to send a video in response to facebook messenger than slack or any other chat client.
If you need to deploy it to your website, you can check this and this out. It supports HTML and markdown components in response so you can send a video.

any way of password masking in AWS lex bot

Is there any way to set data type of the input(in chabox) in amazon lex to password datatype or any way to mask the password shared in the AWS lex Chatbot?
Amazon Lex is entirely separate from the user interface used to pass messages to Lex.
So any configuration dealing with the chatbox, will need to be done within your specific channel's chat display settings. And that will differ between channels (Facebook Messenger, SMS, Skype, etc.).
If you are using the Lex Test Chat, be aware that it has its own unique formatting, built entirely separate from Lex, so don't confuse those two. Lex only deals with receiving messages, parsing the language, and delivering appropriate responses. How the incoming messages and outgoing responses are displayed is entirely controlled by the channel.
Just to give you an example of how something like this can be done using Facebook Messenger.
You can use Facebook Webview to open an html form inside the facebook chat that uses the password input:
<input type="password"...>

AWS Lex and Facebook Messenger Integration Not Working

I'm banging my head against the wall trying to get an AWS Lex based chatbot integrated with Facebook.
As far as I can tell, everything is set up correctly.
When I send a message to my page in Facebook, I don't get a reply. However, the analytics in my app shows that the app is getting messages, so I know the message is making it from the page to the app.
When I try to hit the AWS Lex Webhook directly using POSTMAN, the webhook responds to literally everything I sent to it with a blank HTTP 200 OK response.
The lambda function that is tied to the AWS Lex chatbot is not getting invoked as a result of the messages from Facebook because no logs are getting generated and cloudwatch doesn't show an attempts to run the lambda function.
Does anyone have any ideas?
UPDATE : I ended up engineering around this by bypassing the Facebook channel capability inside AWS Lex and using Lambda instead. I deployed a passthrough API which calls a lambda function and then interacts with AWS Lex via Boto3/Python. In theory this is all supposed to be taken care of from inside AWS Lex with the Facebook channel integration, but I wasn't able to get it to work so I just built around it.
Verify Amazon lex is properly configured with facebook messenger .
Check : Page access token
Verification token
App ID
Check if your webhook is subscribed to page you are messaging on.
Check if your facebook user is added as tester/admin/developer
Check if your latest version of BOt is published on intended alias.
Also while configuring webhook tick necessary options : messages, messaging_postbacks, messaging_optins, message_deliveries, message_reads, messaging_payments
This should resolve your head ache. If not please reply