I have Bot developed in .NET core 3.1 c#. I am sending Adaptive card in OnMembersAddedAsync. It ix expected that as soon as end customer open chat control it should send Adaptive card. This is working well in Azure web chat control & emulator. But when I added it web site and open chat control in web site it will not work. Control will wait for end customer to send some message & then it sends card. In console log of BotFrame.html I can see that DIRECT_LINE connection is established :
DIRECT_LINE/CONNECT_PENDING
DIRECT_LINE/UPDATE_CONNECTION_STATUS
DIRECT_LINE/UPDATE_CONNECTION_STATUS
DIRECT_LINE/CONNECT_FULFILLING
DIRECT_LINE/CONNECT_FULFILLED
My code for BotFrame.html is :
const store = window.WebChat.createStore( {}, ( { dispatch } ) => next => async action => {
console.log(action.type);
if ( action.type === 'DIRECT_LINE/INCOMING_ACTIVITY' ) {…..
}
}
Even in Bot Logs I cannot see OnMembersAddedAsync is called unless customer sends message. Am I missing anything. Same is working well in Azure web chat control & emulator.
This sample, 04.api/a.welcome-event, demonstrates best practice on how to setup Web Chat and your bot for sending a welcome message.
In short, as shown in the sample, you will send an event to your bot when direct line connects your bot and the client.
When the event is received by the bot, it will trigger the bot to send the actual welcome message/card/activity to the user via the client.
In Web Chat
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
// When we receive DIRECT_LINE/CONNECT_FULFILLED action, we will send an event activity using WEB_CHAT/SEND_EVENT
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: { language: window.navigator.language }
}
});
}
In Your Bot
if (context.activity.name === 'webchat/join') {
await context.sendActivity('Welcome, friend!!');
}
Hope of help!
Related
This only picks up when the actual bot gets updated and not when other users update
client.on('guildMemberUpdate' ,(oldMember,newMember) => {
console.log(oldMember['_roles'])
console.log(newMember['_roles'])
});
https://discordjs.guide/popular-topics/intents.html
Read through this page - You need to use intents when connecting to the gateway
so
const client = new Discord.Client({ ws: { intents: Discord.Intents.ALL } })
And enable intents on your application's Page (https://i.imgur.com/XtKjFyY.png) enable both.
I need to send a JWt (access token) to the chatbot via directline. I'm using react as the front end, and the chatbot is integrated into the front end via botframework-webchat.
So far, I was able to send the access token through an activity, which is not recommended as I think.
Right now, the chatbot is asking the user to log in, which is not good because the user is already logged in to the application.
My first question - Is it possible to authenticate the chatbot by an id token instead of connecting with Azure AD, B2C, or any auth service provider?
If it is possible, How can I send the id token to the bot, via botframework-webchat
Thanks in advance
Here is my code for the front end
const Chatbot = (props) => {
const language = localStorage.getItem('language');
const directLine = useMemo(
() => createDirectLine({ token: <my_token>, locale: 'sv-se' }),
[]
);
useEffect(() => {
var activity = {
from: {
id: '001',
name: 'noviral',
},
name: 'startConversation',
type: 'event',
value: 'Hi noviral!',
locale: language === 'en' ? 'en-US' : 'sv-se',
};
directLine.postActivity(activity).subscribe(function (id) {
if (console) {
console.log('welcome message sent to health bot');
}
});
}, []);
return (
<Layout className="login-layout">
<div className="login-div">
<div className="chatbot">
<div className="consent-wrapper">
<ReactWebChat
directLine={directLine}
userID={'001'}
username="Noviral"
locale={language === 'en' ? 'en-US' : 'sv-se'}
></ReactWebChat>
</div>
</div>
</div>
</Layout>
);
};
export default withTranslation()(Chatbot);
Sending the token via an activity is acceptable as activities sent via Direct Line are secure. If you look over the 24.bot-authentication-msgraph sample, you can see that the default action the bot takes is to send an activity displaying the user's token.
As for authentication, the question doesn't seem to be what token you will use but rather how you will authenticate. If you don't use a service provider + login, how is the bot going to verify who the user is? That being said, there are some SSO (single sign-on) options available via Web Chat (see here) that, if a user is already logged in, then SSO could pick it up. You will have to look them over to decide if these options meet your needs.
I am building bot with Bot Builder SDK for Node.js
The bot is for slack
I have configured the slack and botframework correctly, as per the doc Connect a bot to Slack
All communication between botframework, slack and node service is through HTTPS.
The framework is communicating with slack properly.
In Next step, I am working on slack dialog.open
First of all, I could not find any method in Bot Builder SDK, to open the slack dialog, I even tried to Implement channel-specific functionality
Finally I was able to open dialog with direct post to: https://slack.com/api/dialog.open
But when I submit the form, I am getting error:
We had some trouble connecting. Try again?
Please see the screenshot:
The console displays the following error:
Request URL: https://xxxxx.slack.com/api/dialog.submit
Response: {"ok":false,"error":"curl_error"}
Slack send payload with "type":"dialog_submission".
I have tested that by changing the "Interactive Components -> Request URL", to my bot service.
To make slack communicate directly to my bot service.
Reference: section "Add and Configure Interactive Messages (optional)" in Connect a bot to Slack
So, I am sure message is being sent from the dialog box, when I click on submit button.
The message is lost between slack and my bot service. when Request URL is set to: https://slack.botframework.com/api/Actions
I never receives any indication that service is receiving a message.
Please help me to resolve this problem.
Following is the code that I used to open the dialog:
let RESTClient = require('node-rest-client').Client;
let FrameworkClient = new RESTClient();
let Promise = require('bluebird');
openDialogBox: function(token, trigger_id, callback_id) {
return new Promise(function(resolve, reject) {
var dialog = {
"title": "Issue Details",
"submit_label": "Submit",
"callback_id": callback_id,
"elements": [
{
"type": "text",
"label": "Pickup Location",
"name": "loc_origin"
},
{
"type": "text",
"label": "Dropoff Location",
"name": "loc_destination"
}
]
};
var args = {};
args.headers = {Authorization: 'Bearer ' + token, 'Content-type': 'application/json; charset=utf-8'};
args.data = {"trigger_id": trigger_id, "dialog": dialog};
FrameworkClient.post("https://slack.com/api/dialog.open", args , function(data, response) {
if (data && data.ok) {
resolve(data);
} else {
reject();
}
});
});
}
Thanks
As per #JasonSowers (Engineer - Microsoft Bot Framework)
Microsoft Bot Framework do not support this right now.
They may support this in future.
Hi i am using azure process to send the push notification to windows 10
above version hybrid app and i use the below code to send the notification
https://learn.microsoft.com/en-us/azure/app-service-mobile/app-service-
mobile-cordova-get-started-push
i got this document there
pushRegistration.on('registration', function (data) {
this method is not firing is there any process to register before to send
notification
You have to implement a registerForPushNotifications method an call it every time user opens the App:
var pushRegistration = null;
function registerForPushNotifications() {
pushRegistration = PushNotification.init({
android: { senderID: 'Your_Project_ID' },
ios: { alert: 'true', badge: 'true', sound: 'true' },
wns: {}
});
If pushRegistration.on is not called, maybe registration is not complete or there is some error.
Create a breakpoint or print some message in:
pushRegistration.on('error', handleError);
And take a look if it's something wrong.
Also, you can check if there is some missing configuration following the Notification Hubs Diagnosis guidelines: https://learn.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-fixer
I have been using Botkit Facebook Messenger and I can receive text messages from Facebook perfectly, however I can not capture audio messages, images or attachments.
Has anyone been able to capture these types of messages?
var Botkit = require('botkit');
var controller = Botkit.facebookbot({
access_token: process.env.access_token,
verify_token: process.env.verify_token,
})
var bot = controller.spawn({
});
// if you are already using Express, you can use your own server instance...
// see "Use BotKit with an Express web server"
controller.setupWebserver(process.env.port,function(err,webserver) {
controller.createWebhookEndpoints(controller.webserver, bot, function() {
console.log('This bot is online!!!');
});
});
// this is triggered when a user clicks the send-to-messenger plugin
controller.on('facebook_optin', function(bot, message) {
bot.reply(message, 'Welcome to my app!');
});
// user said hello
controller.hears(['hello'], 'message_received', function(bot, message) {
bot.reply(message, 'Hey there.');
});
controller.hears(['cookies'], 'message_received', function(bot, message) {
bot.startConversation(message, function(err, convo) {
convo.say('Did someone say cookies!?!!');
convo.ask('What is your favorite type of cookie?', function(response, convo) {
convo.say('Golly, I love ' + response.text + ' too!!!');
convo.next();
});
});
});
there is an example for stickers, images, and audio replies in the facebook starter project: https://github.com/howdyai/botkit-starter-facebook/blob/master/skills/sample_events.js
If you have trouble using them, feel free to create an issues on the github!