Query URL in Watson Assistant - ibm-cloud

I'm working with Watson Assistant (V2). I'm configuring WA itself through the IBM front-end interface they offer, and use NodeJS to deploy it to their cloud.
I want to do the following:
User visits www.mysite.com/?productID=123 which contains the chatbot
The bot, upon launch, queries the URL and recognizes the productID.
The recognized productID is placed in my entity #productID so I can then use it as context variable $productID (or #productID.literal).
So far I haven't been able to find a way to put the productID in the #entity. I grab the productID by calling an onload function using a regex, and can display the productID in the chatbox. However what I cannot figure out is a way to somehow store this in the #entity.
I'm familiar with html/css/json/js, but not yet with the API that Watson offers.
Any pointers are greatly appreciated. Thanks!

When you use the V2 API for IBM Watson Assistant, then you use message to send user input to the chatbot engine. The request body has a context element with system and skill-related section. You can augment it and set app-related context variables. Use it to pass in your productID. There is no need to try to set it as entity.

Related

Request Body of IBM Watson Assistant for webhook

I'm creating a bot using IBM Watson Assistant. I am trying to use a webhook, but don't know the format of the POST request JSON/HTML which is sent to the webhook.
My case study is a shop where user can pre-order. I want to send the order details to my back-end server and give the user a reference number for the pre-order. I found nothing in the documentation about what POST request format is sent from IBM Watson Assistant and in what format response should be returned.
I know IBM Watson Assistant does not require a particular response format. It allows the developer to manipulate the response as the developer wants.
IBM Watson Assistant has a documented API. There are the recommended V2 Assistant API which can be used to create session and then send messages. The older V1 Assistant API has more functions and is deeper into the system. Both APIs can be used to write chatbots.
If you mean a Webhook as the Watson Assistant feature to reach out from a dialog node to an external service, the process is the following:
in the global configuration, you define the URL and the header
for a dialog node, you enable webhooks, then define the key / value pairs that are sent as payload. They can differ by dialog node.
Typically, the expected result is JSON data because it is the easiest to process.
This IBM Cloud Solution tutorial on building a Slack bot with Watson Assistant uses webhooks to call out to a Db2 database. The code is available in a GitHub repo.

IBM Watson Assistant: Retrieve a specific conversation via IBM Cloud Functions

How can I extract a specific user conversation from all chat logs? I noticed that the chat-log JSON response contains a field named conversation-id.
My goal is to obtain, via Cloud Function, that specific conversation id for the current conversation. So, when the conversation starts how can I retrieve the current conversation id?
The answer is similar to this one:
You can access context variables using either context[variableName] or $variableName. See the documentation on expressions for accessing objects in IBM Watson Assistant.
The conversation_id is in the set of context variables (context.conversation_id). You can access it as part of that structure.

IBM Watson Assistant: How to make API calls from dialog

We have integrated IBM Watson Assistant skill/workspace with a Facebook page using the Watson features. We did this using an integrated approach from Virtual Assistants tab.
We are able to get the response in Facebook Messenger from Watson skill/workspace FAQS. Now we want to add a few more questions to skill/workspace and get the response from a database.
We know that we can use IBM Cloud Functions to get DB data and respond back with the data, but Cloud Functions action types (web_action and cloud_function or server) incur a cost, hence we are looking for another approach.
We have our own APIs developed for the DB and want use those in Watson Assistant dialogue node actions. Please let us know how we can add it in actions and get a response from the API without using client application/cloud functions.
Note: we haven't developed any application for this chatbot, we directly integrated Watson skill/workspace with the Facebook page and trying to call API calls wherever we require them from the dialogue nodes.
As you can see, IBM Watson Assistant allows to invoke three different types of actions from a dialog node.
client,
server (cloud_function),
web_action.
Because for cloud_function and web_action the action is hosted as Cloud Function on IBM Cloud, the computing resources are charged. For type client, your app would handle the API call and the charges depend on where your app is hosted. Thus, there are always costs.
What you could do is to write a wrapper function that is deployed as web_action or cloud_function. Thus, there isn't much of computing resource needed and the charges would be minimal. But again, independent of the action type, there are always costs (maybe not charges) - one way or another...

Is it possible to output google search results in IBM Watson Chatbot?

I have created a chatbot with IBM Watson Assistant. But currently I have hardcoded all values in the dialog
e.g : When some user will ask "Who created Computer ?" then in the dialog flow I have written "XYZ created computer".
But suppose the user will ask about some other person and that value is not hardcoded in the dialogs on IBM Watson Assistant then is there any way by which I can provide Google search results?
You can make programmatic calls from within IBM Watson Assistant dialog nodes. Both server-side actions (IBM Cloud Functions) or client side calls (within the app) are supported. That way you can react to such queries as described and could call a search engine, database or somethin else.
This IBM Cloud solution tutorial on how to build a database-driven Slackbot uses server side actions to interact with a Db2 database. Instead of calling out to a database to fetch data, in your example, you would open a request to Google search.
I saw that you tagged it "facebook-apps". If you use Botkit middleware to build an integration with Facebook Messenger, then check out this blog on how to enable actions in the Botkit Middleware for Watson Assistant.

How to maintain a user model in API.AI (Dialogflow) for a chatbot

I am using Dialogflow to create a chat bot. How do I maintain a user model within a chatbot system?
I want to have a different user model saved for each user in a group. The user model should store the user’s name, personal information it gathers from the dialog, and the user’s likes and dislikes.
With this information, I would like to add personalized remarks from the user model to the dialog engine.
You need some database to story User information.
as per Dialogflow
It's helpful to think of API.AI as just that - an API that you use to
parse user intent from natural language queries. If you have custom
business logic, platform-specific formatting requirements, or need to
integrate with external data stores, it would be better to create your
bot from scratch in code, and make calls out to API.AI in order to
parse inbound queries. API.AI isn't a bot-building platform, but a
Natural Language Understanding platform.
for more Information click here
you can use web-hooks which hits your controller function and run logics which you want like save information.There is one Object like response in which all information inside there
It depends how long you wish to maintain the information about the user and what platform, if any, you're integrating Dashbot with.
Using just the Dashbot framework, one good way to maintain the user information is through the parameters available to a Context. This will be retained during the entire conversational session.
However, if you want to maintain this information between sessions, you'll need to handle this in your fulfillment - in particular, you'll have to save it in a permanent store (such as a database) against a userid if one is provided for your integration.