Dialogflow Push Notification setup not working for actions_intent_PERMISSION - dialogflow-es

I am trying to implement the Push notifications as described here:
https://developers.google.com/actions/assistant/updates/notification
Here are the steps I followed:
Register Action for the Intent as Implicit Invocation in Google Actions.
As you can see, 'notif_intent' is my intent which I want to invoke as a result of a push notification.
In the User Engagement section of this Action, I have enabled the push notification option:
One of my Intent "Setup Push Notifications" is having the keywords like "enable notifications" in order to trigger it, which is used to ask the user for permission for sending push notification. Here is the Inline Editor's nodejs code used to handle this:
app.intent("Setup Push Notifications", conv => {
conv.ask(new UpdatePermission({
intent: 'notif_intent'
}));
});
Another Intent 'FinNotfSetup' is having the event 'actions_intent_PERMISSION' so that it is triggered when UpdatePermission() function is used in above code.
app.intent('FinNotfSetup', (conv) => {
if (conv.arguments.get('PERMISSION')) {
const userId = conv.arguments.get('UPDATES_USER_ID');
console.log("userId", userId);
conv.close(`Ok, I'll start alerting you.`);
} else {
conv.close(`Ok, I won't alert you.`);
console.log("not opted");
}
});
Now when I am triggering the "Setup Push Notifications" intent from my Device/Simulator, the Agent stops unexpectedly every time. On observing the error logs in Simulator, I get following error:
MalformedResponse at expected_inputs[0].possible_intents[0].input_value_data: The intent the app is asking for permission to send updates for is not found."
How is the Intent name not found? Is there any step or config that I am missing?

Related

Microsoft Teams Bot: replyToId seems to be ignored

i am using the microsoft bot sdk in combination with an restify server (In package.json: "botbuilder": "^4.11.0"). I start a waterfall dialog that triggers a long running API. I save the the conversation reference and the id of the sent message to create an reply after the API call is completed:
replyToId = (await stepContext.context.sendActivity({ attachments: [ac]})).id; (in Dialog)
this.conversationReference = TurnContext.getConversationReference(context.activity); (in bot.ts)
After the completion of the API call, I want to create a reply to the last message of the dialog:
await this.adapter.continueConversation(this.conversationReference, async turnContext => {
await turnContext.sendActivity(newMessage);
});
newMessage is the Activity-object that contains further information for the user about the result of the API call.
The problem is that newMessage is not displayed as an reply to the existing message but as a separate message, although newMessage.replyToId is set to this.replyToId:
Additional information: Both messages, the last of the dialog and the "reply" are adaptive cards, but it does not make a difference if I send just simple text, same behaviour.
Would be grateful for any help :)
Instead of using "replyToId", put the id of the message you want to reply to, at the end of the conversation reference. As an example, if your conversationReference has a conversationId of 19:ac....cf#thread.skype, change it to: 19:ac...cf#thread.skype;messageid=12345678, where 12345678 is what you are currently using for "replyToId"

Read data from Firebase in Dialogflow

I am building a chatbot but I got stuck fetching data from Firebase from Dialogflow.
I want a user to input his name, the bot to query Firebase and check if the name exists. If it does "user exists" else "user n not in the database".
[this is the code am using presently][1]
function SaveName(agent){
const number = agent.parameters.number; // when I input the number in Fialogflow
const docRef = db.collection('names').doc(sessionId);
return docRef.get()
.then(doc => {
if (!doc.exists) {
agent.add('No data found in the database!');
console.log(doc);
} else {
agent.add(doc.data().orders);
}
return Promise.resolve('Read complete');
}).catch(() => {
agent.add('Error reading entry from the Firestore database.');
agent.add('Please add a entry to the database first by saying, "Write <your phrase> to the database"');
});
}
This is possible by configuring the fulfillment for your agent.
Go to Intents, select your intent and then scroll down to the fulfillment section.
Click on Enable webhook call for this intent (see Custom webhook).
Create the webhook (you can enable the inline editor at Fulfillment - Inline Editor to do so).
In your webhook, query Firestore (see this answer).
Note that anyone will be able to know if a user exists or not in your db.
If you are building for the Google Assistant, have a look at account linking.
I was facing some similar issue where the fetched details were not being shown in the agent interaction. This happened with the template given here too. I then just removed the responses from the ReadFromFirestore Intent and was getting the expected fetched queries back. I again tried by putting the response back and calling the intent and the response was sort of alternating between the default response and the firestore query response.
Still, not keeping it worked for me and thought would help others too.

Stripe Automatic Confirmation and order fulfillment without Webhooks?

The stripe documentation says when using payment intent using automatic confirmation you should Asynchronously fulfill the customer’s order using webhooks.
If i'm offering a service e.g. ability to download a file once purchased then why do I need to monitor for the payment_intent.succeeded webhook?
If payment succeeded in the following handleCardPayment function then is there still a possibility for the charge to fail? Why shouldn't I allow the user to download the file straight away if the payment has succeeded?
var cardholderName = document.getElementById('cardholder-name');
var cardButton = document.getElementById('card-button');
var clientSecret = cardButton.dataset.secret;
cardButton.addEventListener('click', function(ev) {
stripe.handleCardPayment(
clientSecret, cardElement, {
payment_method_data: {
billing_details: {name: cardholderName.value}
}
}
).then(function(result) {
if (result.error) {
// Display error.message in your UI.
} else {
// The payment has succeeded. Display a success message.
}
});
});
Maybe I've not understood how the handleCardPayment works. Any help appreciated.
When using handleCardPayment, the issue is not so much that the payment might fail, it's that it might succeed but your code doesn't know about it.
handleCardPayment kicks off several asynchronous steps — showing the user a dialog to authenticate a payment with their bank, processing the actual charge against their card, and closing the dialog. It's only after all that completes does the Promise resolve and your function that receives result executes.
Consider the case where:
the customer clicks Pay
handleCardPayment is called
the customer sees a dialog from their bank to authenticate the
payment
they do that, and they consider that their payment is now complete,
and they close their browser immediately.
In this case, your code will never execute, but Stripe still processed the charge. So you don't know that the payment happened and you can't fulfil the order.
That's why it's important to use webhooks, so you get notified asynchronously when the payment completed, even if the user closed their browser mid-process and your code after handleCardPayment never got a chance to run. Alternatively you can use the manual confirmation flow, where the steps are split up and the actual charge isn't processed until your server makes a separate API call.

Integrate Dialogflow with Actions on Google with intents using Fulfillment

When I try to interact with Actions on Google it does not respond when the intent has Fulfillment active.
I receive this error in the logs of Google Cloud Platform:
MalformedResponse: Failed to parse Dialogflow response into AppResponse because of empty speech response
My webhook is responding with a follow-up event input. Here is the response from my API:
{
"followupEventInput": {
"name": "campo-harmonico-found",
"languageCode": "pt-BR",
"parameters": {
"campo-harmonico": "campo harmônico de dó maior ou campo harmônico de ré maior"
}
}
}
The Intent that should call my webhook:
The Intent that should be called after webhook respond:
What is wrong?
I'm not entirely sure what the problem is, but two things jump out at me.
Your campo-harmonico-found Intent has both Training Phrases and an Event set. You should only have one or the other. I would expect that the Event would take priority, but this could be confusing Dialogflow.
It isn't clear that you need to use followupEventInput at all. If your purpose is to just reply with this message - you can just reply with the message from the acorde Intent Handler. Most of the time we don't need to use Followup Events, we should just return the reply that we want from the Intent handler itself.

Unable to trigger event from webhook - api.ai

I need your help with the using of events for communication from webhook to demo chat (https://snag.gy/6tfGEZ.jpg) of api.ai. I have already test in telegram too and it does no work either.
My flow is the following:
The user request something from the api.ai web demo chat. for instance: “Hi, I need my access code”
Api.ai gets the intent and send it to my webhook.
My webhook starts an asynchounous operation to process user request (it could take more than 6 seconds) and returns “We are processing your request please wait a few seconds” to api.api therefore the user will see that message in demo chat.
After the asynchrounous process has been finished the next step will be call POST https://api.api.ai/api/query?v=20150910 with body
{
"event": {
"name": "result_event",
"data": {
"code": "ABDDRR787545HHTTU4545454"
}
},
"timezone": "America/New_York",
"lang": "en",
"sessionId": "a77875da-4bd5-db26-dce2-e42439d4fbde"
}
result_event already exists inside an Intent that contains the response “Your request was processed. Here your code: $code”.
The idea here is the user get the respond to his request for instance: “Your request was processed. Here your code: ABDDRR787545HHTTU4545454”
Althought I get a successfully respond of (https://api.api.ai/api/query) called from my webhook the user don’t get any response in the demo chat.
This is the screen (https://snag.gy/qN3tTC.jpg) of the intent with my event in api.ai.
What do you think I’m doing bad ?
Thanks in advance
Events in API.AI are calling methods for a specific intent. it does not trigger anything so you can not get any triggered for you web-demo bot.
this will work if you can make a custom html bot where you can call events endpoint to get the json data and show it in your html bot.

Resources