I built a bot that is integrated to messenger and default bot on website using dialogflow now the bot have default response and messenger response but when I go to the fullfilment i cant set a specific response for each
here is my code
function time(agent) {
if (currentlyOpen()) {
agent.add(`Hi, We're open now! We close at 11pm today.`);
} else {
agent.add(`We're currently closed, but we open every day at 6am!`);
}
}
I want to have a diffrent response if I am using messenger as the default response goes to the default bot
"I know I can inrtegrate messenger in the website but I want to know this way as I use it for more bots"
You can do that using the same library that you are using for agent. To send specific platform response just add the platform to the response. For example, if you want send a text specifically to Google Assistant then you can do that using agent.add(new Text({ text: 'text_here', platform: 'ACTIONS_ON_GOOGLE'}));.
The full Dialogflow fulfillment code is available on GitHub. https://github.com/dialogflow/dialogflow-fulfillment-nodejs. I have also modified some code to set some other responses that are not available in this library such as telephony transfer and speech responses. So, if you want you can do that too.
Related
I have chat bot, I build it with bot framework nodejs SDK I integrate this chat bot to whatsapp and I want to display some buttons in the whatsapp chat,
So is there any one found a solution for this problem pleas help me
Note: I try to send a hero card but I run to problem
Error: TwilioWhatsAppAdapter.parseActivity():
An activity text or attachment with contentUrl must be specified.
I don't know how bot framework attempts to send WhatsApp messages with buttons, but I doubt it fits with the way Twilio wants to send them.
Currently, to send a message with buttons, you need to register and use a template message. When you send the text of a message that matches one of your templates, then Twilio will deliver the entire template with buttons as well.
For the future, look out for the Twilio Content API which will streamline templates, buttons and other rich messages across platforms.
It looks like you are using the TwilioWhatsAppAdapter from the botbuilder-community-js repo.
Looking at the adapter's code, it doesn't appear to be configured to handle any card other than a 'signin' card (see here). If you don't mind doing a little leg work on this, I don't see why you couldn't fork this repo and build in functionality that supports a hero card similar to the signin implementation.
I imagine it would look something like this:
case 'application/vnd.microsoft.card.hero':
// eslint-disable-next-line no-case-declarations
const hero = attachment.content;
message.body = `${ hero.text }\n\n`;
message.body += (hero.buttons[0].title ? `*${ hero.buttons[0].title }*\n` : '');
message.body += hero.buttons[0].value;
break;
The above may need a little massaging but it wouldn't be far off from this. Then, you just need to build the library for use.
I had written a node js server code so that dialog-flow can connect to my server through web-hook and integrated dialog-flow phone gateway. I am able to get the voice transcript text when made call to that number. But if i type any number on dial-pad i am not getting it. Is there any thing i should do to get the number input from dial-pad on call.
The response is something like this if i say 'hello' on call.
{
"responseId":"b5644842-75bf-41f3-bf84-cf7b4f02c71f",
"queryResult": :{
"queryText":"Hello.","action":
"input.welcome",
"parameters":{},
"allRequiredParamsPresent":true,
"intent":{
"name":"projects/maps-ec9e1/agent/intents/54f5f623-2011-4d95-92a7-b8e873cd55a7",
"displayName":"Default Welcome Intent"
},
"intentDetectionConfidence":1,
"languageCode":"en-us"
},
"originalDetectIntentRequest":{
"source":"GOOGLE_TELEPHONY",
"payload":{
"telephony":{
"caller_id":"REDACTED_IN_STANDARD_TIER_AGENT"
}
}
},
"session":"projects/maps-ec9e1/agent/sessions/l0vQqOpaSsq9rvJc0sMMYA"
}
}
You are looking for DTMF detection. Google's Dialogflow Phone Gateway does not support this, but you can get this capability from some third party Dialogflow Gateway products like Voximplant, Audiocodes' VoiceAI Gateway, and drachtio.org.
There is no standard method for how to do this, but generally the telephony gateway needs to detect a digit and then sends a text query or event to Dialogflow where your bot can handle it.
I wrote reviews at cogint.ai with details on how to do this for Voximplant and Audiocodes.
I am using dialogflow-fulfillment nodejs library to send response(eg: agent.add("<speak>hello</speak>")) back to the dialogflow agent. It works fine with dialogflow agent and google simulator. However, when I use the same response with telephony integration. It does not recognize it as "ssml" and speak it as "greater than speak less than....hello less than slash ..greater than>. Also. I checked SDK supported platforms and it looks like version 0.6.1 does not support telephony Platform yet.
You are correct that the client API doesn't include methods for the telephony gateway, so you'll need to craft the JSON response yourself. This is an example of what you can put for "fulfillmentMessages":
fulfillmentMessages: [
{
platform: 'TELEPHONY',
telephonySynthesizeSpeech: {
ssml: `<speak>YOUR MESSAGE GOES HERE</speak>`
}
}
]
Here's the link to the relevant API v2 beta 1 documentation (scroll down to TelephonySynthesizeSpeech): https://cloud.google.com/dialogflow-enterprise/docs/reference/rpc/google.cloud.dialogflow.v2beta1#telephonysynthesizespeech
Is it possible to format a conversation so that the bot initiates conversation using dialogflow in a web demo integration?
The objective is to say something like “Hi, I’m a bot, I can do x” to establish that it’s a chatbot rather than a human.
Can anyone suggest any idea for this?
You can set a welcome intent, then send a /query request containing an event parameter. Set the event parameter to WELCOME and your chatbot will respond with whatever conversation opening you set.
More info here: https://dialogflow.com/docs/events
If you are using something other than the API for interacting with your Dialogflow agent (Slack, Facebook Messenger, etc.) you will need to add an appropriate event under "intents" in your console (such as the "Facebook Welcome" event).
For interacting with your Dialogflow agent via the API, see below.
In the API interaction quickstart documentation, Dialogflow gives you the SessionClient's detectIntent method for sharing messages with your bot.
Each language has a different solution. But on an abstract level, you want to change the request object that you send to Dialogflow to include a "Welcome" event (no input message required), as Omegastick described.
For example, in Node.js, your request object would look like this:
// The text query request.
const request = {
session: sessionPath,
queryInput: {
event: {
name: "Welcome",
languageCode: languageCode
}
},
};
This assumes you have an appropriate intent set up in your Dialogflow console to handle Welcome events. One is provided by default that you can observe.
You can also add contexts, so that your agent gives a different greeting message based on some condition.
Following this guide:
https://actions-on-google.github.io/actions-on-google-nodejs/
I created an action for DialogFlow
import { dialogflow, Image, Conversation, BasicCard } from 'actions-on-google';
const app = dialogflow();
app.intent('test', (conv, input) => {
conv.contexts.set('i_see_context_in_web_demo', 1);
conv.ask(`i see this only into actions on google simulator`);
conv.ask(new Image({
url: 'https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/imgs/160204193356-01-cat-500.jpg',
alt: 'cat',
}));
});
I then activated Web Demo integration
I saw that the Web Demo integration does not show the cards, the images. I hypothesize that it only shows text, no rich text
I understand that it elaborates only JSON like this:
{
"fulfillmentText": "Welcome!",
"outputContexts": []
}
But I did not find any method in the library used to enhance fulfillmentText
can you help me?
You're using the actions-on-google library, which is specifically designed to send messages that will be used by the Google Assistant. The Web Demo uses the generic messages that are available for Dialogflow. The actions-on-google library does not send these generic messages.
If you want to be able to create messages that are usable by both, you'll need to look into the dialogflow fulfillment library, which can create messages that are usable by the Google Assistant as well as other platforms. Be aware, however, that not all rich messages are available on all platforms, but that the basic text responses should be.
You also don't need to use a library - you can create the JSON response yourself.