keep the session after response in lex - amazon-lex

I'm creating as AWS Lex chatbot with this flow: The user starts saying open my bot and there are a couple of questions asked by Lex, the user has to respond to them and finally a number is generated and this is the Fulfilled slot.
Here is my code:
if (source === "DialogCodeHook") {
if (!sessionAttributes.isFlowDone) {
//multiple questions asked and managed by using Elicit Slots
//once the questions are complete I set sessionAttributes.isFlowDone=true;
} else {
sessionAttributes.isFlowDone = false;
callback(close(intentRequest.sessionAttributes, "Fulfilled", buildMessage(finalMessageWithANumber)));
}
The issue is that, while testing in the AWS Lex chat window, when the number is generated, if you clear the console and type in open my bot, the questions are once again asked and the flow is done as a new request, What I want is that after building the randomNumber, I ask again open my bot without clearing the chat window, it gives me another number instead of asking me the questions (directly the fulfilled callback is called). please let me know on how can I fix this and continue my flow.

Console uses a random user-id (that is sent in PosText/PostContent API) when you test the bot in console chat window. On clicking the 'clear' button console generates another random user-id. Also a bot session is associated with a user-id, so clicking the 'clear' button provides an experience like a new user is talking to the bot (hence all questions are asked over again). Hope this answers your question.

Related

How to send user identification when a user interacts with an adaptive card in a Teams Message

We are using the graph API to send a message to the General channel of a Microsoft Team, which has a number of members.
We would like to allow any members to interact with the message via an adaptive card.
This is doable using say Action.OpenUrl or .Submit, however we need to know which user it is which is interacting. I imagine this must be a fairly common thing to do.
What solutions and options are available to do this?
For example, is it possible to obtain the user's Team id at the time an action is invoked ?
Every activity sent to the bot has a from property that identifies the user that sent the activity. You can see the full activity schema here. I advise you to run your bot in debug mode so that you can see all the data your bot receives. If you want to run your bot in debug mode and talk to the bot using Teams instead of Emulator, you can use tunneling: https://learn.microsoft.com/azure/bot-service/bot-service-debug-channel-ngrok

Telegram bug on iOS bot sending multiple times same message

I think I've found a Telegram bug on the iOS app that causes the bot to send multiple times the same message. The steps to reproduce the problem are:
click on an inline button, type callback
immediately lock the phone screen, before the bot answers
wait a few moments and then unlock the screen
It will be noticed at this point that the bot starts sending the same message numerous times. It is not easy to reproduce, it is important to lock the screen when the bot has not yet answered, so it is easier with bots that take a few moments to respond. Also, in the answer the bot has to send a message (not editing one that already exist).
I use Microsoft Bot Framework to develop the bot, however all the bots give me the same problem, both mine and others developed with other technologies different from mine. For example, I was able to reproduce it on #BotFather too. Sometimes it enters in a loop, and to stop it you have to send any message to the bot.
I use an iPhone 5, iOS version 12.1.2, Telegram version 5.2. I also tried it on an iPhone 8, but not with other versions of Telegram.
I also happen to receive more than 20 identical messages.
I've already contacted Bot Support on Telegram but no one answers me. Is there anyone who experienced the same problem?
On iOS and macOS, when I click on an inline button and switch the client computer (macbook) off (sleep mode) and turn it on my bot receives the last message sent by the user. Each time message_id is the same.
I solve it the following way: when my script sends a request to the Telegram server it receives a response. That response contains a message_id field and I save it.
Any next message must have another message_id. I just compare that number with the stored number and only if the number is other than saved I run the rest part of my script.
You can try my test bot and watch results in google table.
#ios_bug_bot (https://t.me/ios_bug_bot)
https://docs.google.com/spreadsheets/d/1VTx-O1w_-ka1RzGfaVLVBDu0CQxk16QeJTeFYOE4yvo/edit?usp=sharing
The bot source code is here
https://github.com/avtomatron/telegram_bot/blob/master/google_script_bot

Twitter message reply with direct message link not carrying over conversation context

I have a Dialogflow and Twitter integration and all seems to be working fine, except for one scenario.
I have an intent that is looking for negative statements from tweets that mention the Twitter user linked to the Dialogflow integration (lets call it #Target). The purpose of this is to then reply back with a Twitter direct message (DM) link, inviting the person to engage in conversation to further explore their problem.
The scenario steps that do not work are:
Send Tweet to #Target saying for example "Your service is really bad". At this point, the output context is "negative-sentiment" if DF recognises it.
If that is the case, DF then sends back a response with a link that will allow the user to open up a DM session to further explain their issue. In this example they may have a gas supply issue.
The user opens the link in the tweet reply to start the DM.
At this point, I am looking for an explanation of the issue, for example "My gas supply has been cut off". However, if I do that, it does not recognise the intent. I have to at this point re-enter the phrase "Your service is really bad" to get it to register the "negative-sentiment" context, then I can move on.
What does work, is if I start with a DM stating "Your service is really bad", followed by "My gas supply has been cut off". It's almost as if clicking on the reply to tweet either forgets the context or its actually a different DF session that is created once we fall into the DM.
So, has anyone seen this behaviour before? Thank you in advance for your replies.
When you attempt to switch from #mentions to DMs on Twitter keep in mind the sessions don't carry over (they are separate sessions) so what you'll need to do going forward is keep track of usernames on the backend in order to connect the two distinct sessions.

Google Analytics showing message: Bad Event Tracking Code

Google Analytics is showing message "Bad Event Tracking Code" for several my projects. Even for mobile app profile too.
"The message: "The Landing Pages report has a (not set) entry. Verify that tracking code for property (my app name) sends a _trackPageview hit and that it does this before sending any events."
Has somebody got similar issue?
and how to solve this issue because I read about this and can't figure out what is wrong.
I think an issue with you tracking code that have to generate with you google analytics account Here it is step by step description about how to Setting Up Google analytics for Your App
step:1
Go to www.google.com/analytics. The homepage should appear like so:
step:2:
If you do not have a Google account, you will need to create one now by selecting Create an Account on the top-right side of the page.
or sign in in this page.
Once you have logged in, you simply need to click the Access Google Analytics button on the top right.
Step:3
The first screen you see lists all of your accounts.
If you have clients, typically you will have one account set up for each.
If you are new to Google Analytics you will only have the first account you set up.
step:4
Select the Admin view on the top right.
To see the main dashboard area for managing your Accounts, Properties, and Views.
step:5
Select the Property drop-down and click on the Create new property item, like so:
step:6
Google then asks you to submit the details for the app you want to track.
Make sure to choose Mobile app at the top and enter the information as required.
In the Setting up your property section, enter "Cloud App" for the App Name.
step:7
After accepting the terms of service, the website takes you to a page with your tracking ID and the download link for the SDK.
Before you do anything else, write down your app’s Tracking ID, which will be of the form ID UA-XXXXXXXX-Y.
Keep the ID handy, because you will need it soon. For full of description please visit raywenderlich blog
I have received similar errors. However, after testing and checking all the tags, all seem to be in order. I read on PBS that these are false positive alerts, where the errors in fact in correct.
http://spiblog.pbs.org/2014/08/the-art-of-analytics-google-analytics.html

How to share links via FB App when I am offline

I am developing an mobile app for iPhone. The app will primary used by people who are on holiday in a different country and will be offline most of the time, due to high costs for internet traffic.
However, the company for which I am developing the app wants to users to be able to use the "Facebook Share" functionality also when people are not connected to the internet.
It should work on a way that they click the SHARE link button in the app, but then get a message that they are offline and the link will get shared as soon as they are online again.
I am trying to figure out how to do this. Can I pass the link I want to share to the official FB App via fb:// protocol (or whatever) and the FB App handles the post/share as soon as it is online again?
Or do I have to do it on my own, put the links I want to share in a internal database and then post them to the wall when I am online again?
Or any other ways??
Any suggestions would be welcome, I would prefer a very quick solution and hope someone maybe has an idea how to do this. I was hoping I can pass the share-link to the official FB App and this one handles everything when it goes online again !?
Thanks for your ideas!
Your approach should be to make your link-sharing code automatically cache requests until they are sent. The app then doesn't need to concern itself with the details - it can just post the link and get a 'failed', 'success', or 'postponed' response from your API and notify the user accordingly.
Your link-sharing code can then internally check if it can currently post to FB and if not (either because the user is currently offline or perhaps the Facebook token is expired) it will store it for later. This class will then re-check periodically (for example when the app comes to the foreground or when the class is initialised the next time the app starts) for connectivity and then it will check if the token is still valid and perform FB login if required. Once it has a valid token it can then iterate through the pending requests and act upon them.
If you really want to make it nice and clean, you can separate out the code that accepts incoming requests to do something, checks if it can be performed now, does it or stores it for later, and periodically checks any requests in the pending queue. This class will not have any idea what the requests do or how they are performed, it will work with another class that implements a protocol to do the actual work and knows about facebook, etc. There may even be an existing design pattern for such a setup, but I don't know what it's called if there is.
Update: I did some research and found this is very similar to the "Fire-and-Forget Pattern".

Resources