Kik bot static keyboard does not appear - node.js

I was experimenting with a kik bot using Node.js, while I was trying to get a static keyboard to appear when user sends a 'help' message, it only sent the two replies and the static keyboard does not pop up. According to me it should work.
This is the function that sends the help messages:
/**
*
* #param {Message} message
*
*
*/
function help(message) {
message.reply('Hello!');
message.reply('Choose from the options to get an idea of what I can do! ;)');
message.addResponseKeyboard(['Rate me', 'Set reminder', 'Info']);
}
This is the bot configuration:
let bot = new Bot({
username: 'purppbot',
apiKey: 'dba843db-18bb-45fe-b6d6-3a678f420be2',
baseUrl: 'https://purppbot1-xbeastmode.c9users.io/',
staticKeyboard: new Bot.ResponseKeyboard(['Help', 'Info'])
});

I honestly don't know about Node.js; but as far as I see, I think you are expecting Static Keyboard to do what a Suggested Response Keyboard would do.
Regarding Static Keyboard, according to the API Reference of Kik docs, The static keyboard allows you to define a keyboard object that will be displayed when a user starts to mention your bot in a conversation, whilst regarding Suggested Response Keyboard, A suggested response keyboard presents a set of predefined options for the user.
It means the static keyboard is shown when a user starts to mention your bot in a conversation; and it disappears once a message is sent to the bot. And when the bot sends back a message to the user, it will contain its message(s) and Suggested Response Keyboard sent by the bot along with the message. In case no Suggested Response Keyboard is sent by the bot along with the message(s), the static keyboard is not shown until the user again starts to mention the bot's username.
So, in your case, you might want to send the those responses through Suggestive Responses Keyboard, which your bot would need to send along with the text message, every time a user sends the 'help' message.
I hope this helps.

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"

Retrieving PSID from messaging_optins

I'm a new developer building a facebook messenger chatbot using node.js and Microsoft's BotFramework. I've got my chatbot up and running nicely and I'm now trying to personalise the welcome message with the user's first name.
I have a welcome message set up when a user clicks the "Get Started" button and I believe I should be able to retrieve the PSID using messaging_optins.
If so, I've got a a function that processes the Facebook payload in onEvent from the EventActivity.Value:
This cycles through some if/else statements to detect whether the Facebook payload is a Postback, Optin or Quick Reply:
If an Optin is detected it then prints "Optin message received" to the console:
The problem I'm finding is that my code isn't detecting the Optin message and so I'm not then able to write any code to extract the PSID to use to personalise my welcome message.
Can anyone point me in the right direction?
I’ve solved this as I found from the documentation here that it’s messaging_postback that are sent when 'Get Started' is clicked.

In a chatbot conversation using dialogflow, Is there a way to make the bot speak first?

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.

Can a slack bot message another bot?

I have a bot, and I can interact with it. And there's another bot, and I would like my bot to chat with that bot, when they are in the same channel. Is that even possible?
I tried to include a mention like <#IDBOT|name>: text, and even though it appears to me that the mention was successful, the other bot doesn't respond. If I post this mention it will work.
Is there a limitation here?
Yes, it can.
I had the same problem, it turns out that I had included some code that I didn't understand, and that code was preventing the response. I e-mailed slack about it and they set me straight.
The problematic code was this:
if event["type"] == "message" and not "subtype" in event:
user_id, message = parse_direct_mention(event["text"])
if user_id == self_id:
return message, event["channel"]
The helpful response from slack:
The condition below is what's preventing your bot from listening to bot's messages:
if event["type"] == "message" and not "subtype" in event:
When a message is sent by a bot, it will have a subtype, so this means that your logic is disregarding any bot message.
This is helpful because it prevents your bot from responding to its own messages, which would create an infinite loop.
You'll need to modify this condition so that your bot still "ignores" its own messages, but processes messages from other bots. You could do this for instance by looking at the bot ID or user ID and discarding those messages, but not messages from other bots.
In my case, I want the bot to respond to humans always, and bots only if they are trusted, so I did this:
from_user = "subtype" not in event
from_friend_bot = (event["subtype"] == "bot_message") and (event['username'] == f'{ping_source}')
if from_user or from_friend_bot:
user_id, message = parse_direct_mention(event["text"])
if user_id == self_id:
return message, event["channel"]
Yes, bots can talk to each other in a channel.
It depends on how you control the listening bot. I'm using a fork of the official Python Slackbot code (https://github.com/bscan/python-slackbot) and in it, I check for <#U1234567> where U1234567 is the user_id of the bot. When you mention #mybot, Slack replaces #mybot with <#U1234567> in the message. However, when posting as a bot, Slack doesn't replace a callout with the user_id. Instead, a bot can directly put <#U1234567> in the message (and post using as_user=True). Slack will display <#U1234567> as #mybot in the channel and the bot will be able to detect it if looking for that exact message string.
Source: played around until bots talked to each other.

Is it possible to send the location from Telegram to Bot?

Is it possible to send the location from Telegram to Bot, which made in Bot Framework?
I send my location from my Telegram account to my Bot, but the server does not get them (I don't get the response).
Text messages send normal, and I get response from the server.
Code is very simple:
public async Task<Message> Post([FromBody]Message message)
{
return message.CreateReplyMessage("Tadaa");
}
Dang it, this is a bug. We are filtering out messages without content and we are not treating the location property as "content". To us it looks like no text, no attachments, no channeldata and so no reason to send the message. I will push through a fix.

Resources