I'm currently trying to implement a prompt for push notifications in my dialogflow webhook. It works fine and sets the user up for push notifications if I implement it in the fashion described in the actions on google documentation (https://developers.google.com/actions/assistant/updates/notifications)
conv.ask(new UpdatePermission({
intent: 'send_notification'
}));
When the user activates this section of code they are prompted with
Is it okay if I send push notifications for my_updates_intent?
There is no problem with this message, however, I wish at the very least to prefix it with a message of my own so that I can display this prompt contextually, depending on where the user is within the conversational flow. For example:
Your email has been set. We can set up notifications to keep you informed. Is it okay if I send push notifications for my_updates_intent?
Or
No problem, we wont send you an email. If you are interested, we can set up notifications to keep you informed. Is it okay if I send push notifications for my_updates_intent?
Using the Permission constructor, the one UpdatePermission inherits, I can set a context that allows me to do just this.
conv.ask(new Permission({
context: "So we can give you directions",
permissions: ['DEVICE_PRECISE_LOCATION'],
});
Which will respond with:
So we can give you directions, I'll just need to get your street address from Google. Is that ok?
The first half of that message being something I wrote, and the second half coming from Google based on the type of permission I am requesting.
Logically I assumed that perhaps I could approach this by using the base Permission constructor with the permissions set to UPDATE:
conv.ask(new Permission({
context: 'Your email has been set. We can set up notifications to keep you informed',
permissions: ['UPDATE'],
updatePermissionValueSpec: {
arguments: undefined,
intent: 'send_notification'
}
}));
This, however, responds just the same as the UpdatePermission constructor and completely ignores my context. I have not been able to find any documentation or online resource that addresses this issue. Is it at all possible? or am I missing something obvious?
After contacting the actions on google support, I learned that customisation of the UpdatePermission message is not currently possible.
From the support team:
Unfortunately, altering this message is not possible for updates and push notifications. I'm adding this to our system as a feedback.
Hopefully, this helps anyone else facing a similar issue.
Related
Update: June 30, 2020
After more testing, I have details that might help someone recognize my problem.
The issue seems to be that Slack is sending data to Azure Bot Services, but that data isn't being forwarded to my code. Ive been able to use the Bot Emulator without any problems and the Azure Web Chat works fine.
I know that the Slack configuration for the OAuth Redirect URL is correct (I was able to add my bot to Slack) and the Request URL for Events is correct (they sent the 'challenge' and it's verified). I've subscribed to the exact Scopes and Events that are in the Microsoft documentation and I've verified that the Interactivity and Events options are enabled.
When a user types text in my bot's Slack channel, my app receives "message" activity and my code can send a response, so it looks like Microsoft can communicate end-to-end for normal messages. I do not receive any data when users first join my bot (like a ConversationUpdate) or if they click a button in a dialog. I can see Slack sending data when a button is pressed, it just never arrives.
As a test, I copied the Messaging Endpoint from my Azure bot settings and pasted it into Slack's Interactivity "Request URL" and when I click a button in Slack I can see the data that Slack is sending (sadly in a format that my code can't handle).
Original Post
I have a Bot Framework app (v4) that I've written in nodejs. It works well and I have an ActivityHandler that responds to people being added to a conversation and when they send messages. I was able to get pro-active messaging functioning and everything was great until I tried to get interactivity working.
I started off using some sample button code from Microsoft's documentation:
let reply = MessageFactory.suggestedActions(['Red', 'Yellow', 'Blue'], 'What is the best color?');
await turnContext.sendActivity(reply);
This works fine in the emulator, but in Slack it renders as a bulleted list. It looks like that's the way that "suggested actions" are handled in Slack.
I changed my code to use a "hero card":
let card = CardFactory.heroCard(
'What is the best color?',
undefined,
CardFactory.actions([
{
type: 'imBack',
title: 'Color Red',
value: 'Red Value'
}
])
);
let reply = MessageFactory.attachment(card);
await turnContext.sendActivity(reply);
This works okay in the emulator, except my app thinks the user typed "Red Value" and the button stays on-screen and is still clickable. I might be able to work around that, but the button doesn't work at all in Slack. It is rendered fine, but I don't get a notification in my app.
Clicking the button shows an HTTP request to:
https://{MY_SLACK}.slack.com/api/chat.attachmentAction?_x_id=f8d003c3-1592436018.632&_x_csid=NcWi3y50lFU&slack_route={OTHER_SLACK_STUFF}
And I can see that the request POSTs all sorts of data including:
payload: {"actions":[{"id":"1","name":"imBack","text":"Color Red","type":"button","value":"Red Value","style":"default"}],"attachment_id":"2","callback_id":"{MAGIC_NUMBER}:{TEAM_ID}","channel_id":"{CHANNEL_ID}","message_ts":"1592435983.056000","prompt_app_install":false,"team_id":"{TEAM_ID}"}
I'm not sure how to see anything useful in the Azure Portal - the analytics option for my bot doesn't seem to work and the activities option only says "Write a Bot Service". I don't see any sign of the message going from Slack to Azure.
I'm developing locally and configured ngrok so that my messaging endpoint in Azure could be set to https://69fe1382ce17.ngrok.io/api/messages On the Slack side of things, I've configured the Interactivity Request URL to be https://slack.botframework.com/api/Actions The Event Subscription Request URL is https://slack.botframework.com/api/Events/{MY_BOT_NAME}
What I would like is a set of buttons with different options and when the user clicks one, my bot gets some sort of "value" instead of message text. I'd also like for the button to go away so the user can't send repeated commands. It would be nice if the hero card collapsed with just the prompt being displayed.
Are there any interactive options that work for Slack and other channels?
Thanks!
Lee
I know linking to another site with no additional detail is frowned upon, but I don't have enough expertise to answer your question. I suspect the link here might move you in the right direction:
Choice Prompts are not translated over to Slack format #3974
Good luck!
Your question is multifaceted so I'll try to break it down into smaller pieces.
What's the deal with suggested actions in Slack?
Suggested actions are not supported in Slack, but the Bot Builder SDK thinks they are. This is a longstanding bug. I've just reported it again on the docs page you linked: https://github.com/MicrosoftDocs/bot-docs/issues/1742
This means you would encounter problems if you were trying to have the choice factory automatically generate the right kind of choices for your channel. You're not doing that, so you should be fine. Hero cards are supposed to work in Slack.
Why aren't hero cards working in Slack?
First I need to mention that hero cards only work with the Slack connector and not the Slack adapter. You seem to be using the connector so you should be fine.
I suspect your problem is related to how you've configured your bot's settings on the Slack side. There is a step in the Bot Framework doc that seems to be important if you want to get buttons to work. If you've followed the doc exactly and you still can't get buttons to work, it may be worthwhile to dig into the Slack API documentation.
How do I only allow a button to be clicked once?
You can update or delete the activity. There's no easy way to do this, but if you voice your support for my cards library then it can be done for you automatically.
The Slack connector actually puts a lot of relevant information in the incoming activity's channel data, and you can use that to figure out what activity the incoming activity came from. That would take some experimentation on your part.
There's another approach that works on more channels than just Slack. It's real complicated, but if you wanna tackle this then here are the basic steps:
You need to put an ID in the action data to help your bot identify the action.
You need to save the activity ID that gets returned when you send the action to Slack.
You need to associate the returned activity ID with the ID you put in the action data.
You need to retrieve the activity ID using the action data ID when the user clicks the button.
You need to use that activity ID to update or delete the activity.
Unfortunately there's no centralized guide to help you do this, but there are many examples explaining it scattered across Stack Overflow. Here is a good one: https://stackoverflow.com/a/55174866/2122672
I'm building a Telegram bot for myself that should send to me notifications when I get any. I'm trying to achieve the same behavior as GitHub's email notifications. The problem is that I'm not sure if it's even possible. I'm working with GitHub API for few days straight trying to solve this issue but I still have no idea how to do it. It's like GitHub API doesn't provide enough information about the notification.
For example, it provides field "reason", which describes why I got this notification but how to understand what this notification is about? Like, if I was assigned to the issue or pull request (right now it seems like notifications are the same whether I got assigned to the issue or got a new message in the assigned issue), or got a new message in a watching issue/pull request or anything else.
I have been working with Google Dialogflow to create a Google Assistant experience.
My GA Action is to Raise Support tickets and those tickets are raised in our system via API.
We ask the user to describe the Issue they are facing, We have used a fallback Intent to capture the Issue/Ticket Description(Since the reply can be any free text, is this the best way to capture free text?).
Once the user gives a description, A webhook is called and the results are sent to our backend to capture.
We have noticed that when the user uses the words "not working" as a part of the issue description, it always calls the welcome intent, instead of going to the follow up Intent. If the user describes the Issue without using those words, it works fine. Below are 2 different responses.
I personally feel that this is a bug in GA, is there any way to solve it?
I think you're doing some things wrong. I don't have enough information to understand 100% what you are doing, but I will try to give you some general advice:
A fallback intent is used to 'fall back' to this intent when a user asks something that is nowhere provided in one of your other intents. That's why your fallback intent has the 'input.unknown' set as action. It will be triggered when the user gives some input that is unknown for your application. F.e. I don't think your '(Pazo) Support Action' will provide an answer if the user asks to book a plane to Iceland, so that's when your fallback intent comes in to give an answer such as 'Sorry, I can't answer that question. Pazo is here to give you support in... What can I do for you?'
Your user can either register a complaint or raise a support ticket if I'm getting this right? I recommend you to make two seperate intents. One to handle the complaints and one to handle the support tickets.
Before developing advanced actions with a seperate webhook and a lot of logic with calling an API etc., I recommend to go through the documentation of Actions on Google:
https://developers.google.com/actions/extending-the-assistant
I'm struggling through the official Documentation of how to setup push notifications in Actions on Google. I did find this Github project here.
However I'm still unclear on the exact steps of setting up an intent in dialogflow to acheive this. I am using webhooks for all of my intents currently.
Question #1:
On the official documentation it talks about referencing the event actions_intent_PERMISSION. However, I have an intent set up for this event already when i ask to get the users location. Do I set up a separate intent to handle the user permission for push notifications, or do I somehow handle both permission grants in a single intent?
Question #2:
How many intents do I need to properly execute this user flow?
DF: "do you want be notified of severe weather"
User: "yes"
DF: "i'll need to get permission to send you notifications, is that ok?"
List "yes"
* how many intents occur here *
What I'm hoping to find is a more concrete example of how to set up a push notification on google actions using dialogflow.
Nick Felker had a good link, I'm not sure how I missed this example, but it is a much more clear example of how to build out push notifications in dialogflow with Nodejs fulfillment.
Thank you for the link:
https://github.com/actions-on-google/dialogflow-updates-nodejs/blob/master/functions/index.js
I am having some problems with my Alexa skill. I would like the dialogue to go like this:
User: 'Alexa, open party'
Alexa: 'Hello, what is your four digit secret pin?'
User: '1234'
Alexa: 'Confirmed, what can I help you with?'
But I am confused on how to structure this. I need to take the user's pin and verify it in my codebase. I know you cant get dialogue delegation to work inside of the LaunchRequest. The LaunchRequest can not be customized, so I cannot add slots to it. I can't find any other suggestions/examples on the internet. Has anyone done this before or are there any suggestions?
Amazon supports account linking as the method to connect users with their other accounts. This allows users to log into their other account using OAuth at the time the skill is installed. While it may be possible to determine a user based on the session object userid, it may be difficult to get such a skill published.
It turns out that you can not delegate slot collection to Alexa within the LaunchRequest, because it is not part of a valid response type for LaunchRequest.
My Initial logic was:
User says 'Alexa, open party'
Alexa Skill calls LaunchRequest. (At this point I need to ask the user for their pin by delegating Alexa to do slot colleciton)
In the LaunchRequest, immidiately respond with this.emit(':getPinIntent'); where getPinIntent is another intent existing in my Alexa Skill. The above code is what I saw on the internet for how to call another intent without the user having to provoke using voice.
getPinIntent gets called and immediately it checks to see if all the required slots are filled (i.e. if the slot PIN has a value). If they are not and dialogState !== 'COMPLETED' then I delegate the slot collection to Alexa.
The above step (#4) is where things go wrong. Because delegation is not a valid response type for LaunchRequest's, there is no field dialogueState which is required for delegation to Alexa. The Alexa Request is still a LaunchRequest instead of an Intent request because the user did not invoke the intent by saying something to Alexa.
In conclusion this is not a valid way of completing a dialogue where upon launch the user is asked for a pin and then can reply by only saying that pin, visualized below:
User: "Alexa, open party"
Alexa: "What is your pin" (alexa never gets here, because of #4 and #5 above)
User: "one two three four"
Alexa: "Confirmed, what can I help you with?"
If I have made any mistakes or wrong assumptions please let me know.
My current logic has now changed. If you do not use the Skill Builder Beta you can have a slot exist as an utterance for one of your intents. So I now have getPinIntent with a slot called {PIN} and an utterance in the form of {PIN}. This lets the above type of conversation happen because when the user says his or her pin back ("one two three four") it starts the getPinIntent where I can then continue OR delegate the dialogue to Alexa because for IntentRequest dialog is a valid response type.
The only problem I have now is that because I am not using the Skill Builder Beta I can not (or have not found a way) to add Dialogue Models to/inside of my Intent Schema. I have tried copying the JSON text from the Skill Builder Beta into my Intent Schema after adding the correct Dialogue Model, but this always results in build errors.
So now I can complete the user's pin authentication and respond with a "How can I help", but the IntentRequest that comes after that may require delegation to Alexa for slots, and this would cause a crash because without the Skill Builder Beta I am unable to add the appropriate dialogue models for Alexa to use during delegated slot collection.