Conversation flow works in 'Try it out' but skips child node in app - ibm-cloud

I am making an app that predicts clothes the user is wearing. It uses the Visual Recognition tool, too, and for Conversation and VR to be communicating, I attach the intent 'suggestClothing' or 'clothResult' to the cloth items it found. I use an entity for Conversation to recognize the cloth items and respond accordingly.
The flow should be as follows:
User: how do I look?
-classifies clothes-
App to conversation: clothSuggest blackJacket
Conversation to user: "You picked the black jacket! Try out the green shirt with this outfit and show me how you look."
-classifies clothes-
App to conversation: clothResult blackJacket greenShirt
Conversation to user: "You look great in that outfit!"
All nodes have multiple responses as all clothes are in pairs. Either the user is wearing one or the other, and Conversation will then always suggest it's match.
Conversation flow looks like this
I also attempted this. Here sq123 is suggestClothing (first intent) and cq123 is clothResult:
This works fine in 'Try it out', too, but in the app, it immediately exits the branch on 'clothResult item1 item2' and matches with other conditions in the app.
What's the best way to optimize my flow to make it work in the app?

A typical reason why it works in "Try it out" and not in the app is that the context object is not returned properly.
When the app invokes the message method of the Watson Assistant API, a context object is passed. The calls are stateless and everything needed for Watson Assistant to continue a dialog is included in the context object. Thus, when your app retrieves the results from the message API, it needs to save the context and pass it back to Watson Assistant the next time the message method is invoked again (for that session and user).

Related

How to prevent google action from closing the conversation?

I'm developing a Google Action through DialogFlow and a webhook (that will run on a Nest Hub) that I want to act like this:
the user invokes the action "Hey Google, talk to ACTIONAME"
through the Default Welcome Intent ("hooked" to my web service) the Action replies to the user and open a website
app.intent('Default Welcome Intent', conv => {
conv.ask('Hi! I'm opening your site')
conv.ask(new HtmlResponse({
url: 'https://MY_IOT_SITE'
}))
})
now, the user could be "silent" for mins or hours, but I'd like to prevent Google Actions to close the ACTIONNAME and return to the clock, while until now the action closes after a couple of minutes
Is it somehow possible?
Thank you.
This is not possible. The platform intentionally places an upper bound on how long an action can run without any user input. This is done so that an action cannot occupy the device longer than expected and prevent future inputs from unintentionally getting routed to your action rather than the Google Assistant.
You can take a look at additional guidelines when developing your web app.
Since your question refers to an IoT-related website, you may want to take a look at the Smart Home reference, which provides an alternative way to let users control smart home devices with their voice or built-in graphical widgets.

How to trigger a specific node in IBM Watson Assistant from URL

I have a website which links to a chatbot built on IBM Watson Assistant. There are some hyperlinks on the website that I want to trigger specific nodes/ intents the watson dialog.
Example: User clicks on "Provide feedback" link, the watson chatbot launches and based on the link the "provide_feedback" intent is recognised (thus preventing the user from needing to specify the intent after clicking the link).
Has anyone tried this before?
I also came across this requirement and want to mention another alternative here:
Instead of sending an input text that matches the intent of your desired node, you can also pass
Intents to use when evaluating the user input.doc
and tell the assistant to match it with confidence of 1.0.
I think this is a clean method, because you don't need to deal with disambiguation of your input text.
Then you don't need to send input text at all and the intent actually does not even need example phrases :-)
For example if you want to trigger a node that has the intent #provide_feedback
you can call this python example code:
send_message_to_chatbot(text="", intent="provide_feedback")
def send_message_to_chatbot(text="", intent=""):
message = assistant.message(
assistant_id=ASSISTANT_ID,
session_id=SESSION_ID,
input=MessageInput(
text=text,
intents=[RuntimeIntent(intent=intent, confidence=1.0)]
)
).get_result()
return message
Prerequisite is of course that the node is in the root branch of your dialog so it can be triggered.
The Watson Assistant service basically is used via a REST API. That API is invoked from the "Try it" pane in the workspace editor, from your dedicated application or maybe from widgets embedded into a website. The message call is used to send user input to Watson Assistant and to receive a chatbot response.
What you can do is to call the message API from your app and pass a specific term as input message. That term would match an intent and hence trigger a specific dialog node. As an example, if you have an intent "provide_feedback" defined for the phrase "user pressed feedback button" and you pass in exactly that phrase as input message, then the intent "provide_feedback" will match.

MS Bot framework i want to put a form builder in an open conversation

I want to start Form conversation chat in Microsoft Bot framework.
if(user says hello)
{
reply = what u want to listen hi or hello
if(user says order)
{
reply= start a formbuilder.form with order form workflow
}
if(user says hello)
{
reply= hello
}
}
My problem is the first thing i do always works
example: if i say first chat line as order it starts order form but it never goes to the normal conversation mode even if the form ends.
if i start hi then it always goes in hi mode never goes or create order form on typing order.
Need it to be dynamic
you can use below code to end your conversation when you are in a dialog or a conversation flow ends.
context.Done<object>(new object());
or
context.Done(true);
do let me know if you need any help further
Per my understanding, you want start specific dialogs while triggering different words like "hollo" for greeting dialog, "order" for form dialog.
I think there are two methods to achieve this in C#:
You can leverage Recognize intents to implement LUIS, which can identify your users' intent from their spken or textual input, or utterances. Trigger specific dialogs for each LUIS intent.
For this solution you can refer to the official document Recognize intents and entities with LUIS using a prebuilt domain for details, and refer to https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/intelligence-LUIS for a sample for your reference.
You also can build Global message handlers using scorables in your bot application for yourself. With which, you can route users to certain fuctionality by using words like "help," "cancel," or "start over" in the middle of a conversation when the bot is expecting a different response.
Please refer to https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-GlobalMessageHandlers for the sample for this solution.
Hope it helps.

FB Chatbot how to get the previous message

Is it possible to receive the previous message that the user have send to the chatbot (without using quick replies or postback buttons). Example:
User: "Can you call a friend?"
Bot: "Who should I call?"
User: "Tim"
In the API I now have just the information "Tim", without knowing if I should call him or text him or make him a sandwich or whatever. So I basically I want to add some Postbackdata or metadata additionally to the text "Can you call a friend" (intent: 'CALL'), so the message "Tim" will come with that data.
Is there a way without storing the data into a database? AWS Lambda with ClaudiaJs.
I found the metadata field in the FB API which turns out to be the wrong field for that since it is only for communicating between several apps?!
What you are looking for a called a "slot-based bot", or slot-filling, basically meaning that you have a "slot", or blank that needs to be filled in before your bot can perform an action. In your example you have two slots: action and person
Actions could be: call, text, message
Person: name of a person, friend, etc.
I don't think any of the message frameworks (Slack, Facebook, etc) will provide you with the information you need. You will need to build this logic out yourself.
You can look at using wit.ai stories to achieve this.
Look to this similar Stack Overflow question and answer.
You can reverse order of conversation, and at beginning user writes some text or send you something else. After receiving, you should send to user buttonsTemplate, where postbacks will be like "CallTo&Tim" where instead of Tim you can put every text you need to pass to next executor(and you also can store previous user message here). Than just make substring of postback, check it`s type and do whatever you want.

What is the name of the App Launch event for Facebook Analytics?

I'm trying to implement the new analytics for a Facebook game (using HTML/Javascript and Flash on Canvas, so there is no mobile version), but it seems that the documentation is incomplete. It says that there are 14 predefined events:
"Events are one of 14 predefined events such as 'added to cart' in a
commerce app or 'level achieved' in a game"
Source: https://developers.facebook.com/docs/reference/javascript/FB.AppEvents.LogEvent
"The fourteen pre-defined events are: App Launch, Complete
Registration, Content View, Search, Rating, Tutorial Completed, Add to
Cart, Add to Wishlist, Initiated Checkout, Add Payment Info, Purchase,
Level Achieved, Achievement Unlocked, Spent Credits."
Source: https://developers.facebook.com/docs/app-events/faq
However, on the reference page where all the events should be listed, the list is only 12 items long, and there is no "App launch" event:
https://developers.facebook.com/docs/reference/javascript/FB.AppEvents.LogEvent#events
Now, there are some sample event lists for some games, but they are very basic and they don't include the actual code: https://developers.facebook.com/docs/app-events/best-practices#casual
which recommends to use these events:
App Install
App Launch
Completed Registration
Completed Tutorial
Level Achieved
Achievement Unlocked
(...)
Here is what I have so far:
FB.AppEvents.activateApp()
But is this event the equivalent of App Install or App Launch?
Also, should I send this before the user accepts to share his basic info or after? I'm having so many questions because it's not clear what activateApp() does...
Here is some code for sending some other events that could be useful:
FB.AppEvents.logEvent(FB.AppEvents.EventNames.COMPLETED_REGISTRATION);
FB.AppEvents.logEvent(FB.AppEvents.EventNames.COMPLETED_TUTORIAL);
var params = {};
params[FB.AppEvents.ParameterNames.LEVEL] = '12'; //player level
FB.AppEvents.logEvent(
FB.AppEvents.EventNames.ACHIEVED_LEVEL,
null, // numeric value for this event - in this case, none
params
);
I still have more questions: how can I properly send the game version number (maybe with activateApp?) so I can create segments and cohorts later? Some example codes would be really appreciated!
Thanks in advance!
FB.AppEvents.activateApp() provides install and launch event functionality, which is why those two events are not enumerated as options in https://developers.facebook.com/docs/reference/javascript/FB.AppEvents.LogEvent#events. Activate app doesn't take a parameter. You might want to look at using a custom event to satisfy your use case.