Botframework-sdk: How to start with self initiated bot configured for direct line and SMS?

Created on 6 Sep 2016  路  16Comments  路  Source: microsoft/botframework-sdk

I need to ping user with a message like 'Gentle reminder for outstanding payments'... How to we initiate conversation to a specific user from bot framework node.js configured for Twilio SMS

Most helpful comment

got the solution for facebook, we have to send address something like this for facebook

bot.dialog('/notify', function (session) {
session.endDialog("I'm sending you a proactive message!");
});
bot.beginDialog({"channelId":"facebook","user":{"id":"id of the user"},"bot":{"id":"id of the bot"},"serviceUrl":"https://facebook.botframework.com","useAuth":true}, '/notify');

All 16 comments

You can find more information in these two threads that solve the same issue:

Hi palmerabollo, i have the same issue, i am trying to figure out the fields to be filled in from and to,
bot.beginDialog({
text: "I'm sending you a proactive message!",
language: "en",
to: { address: "User1", channelId: "emulator" , id: "2c1c7fa3"},
from: { address: "stuffbot", channelId: "emulator", id: "stuffbot" }
},
"/"
);

i can figure out id, could not figure out address, how to get address of the user and bot

got the solution for facebook, we have to send address something like this for facebook

bot.dialog('/notify', function (session) {
session.endDialog("I'm sending you a proactive message!");
});
bot.beginDialog({"channelId":"facebook","user":{"id":"id of the user"},"bot":{"id":"id of the bot"},"serviceUrl":"https://facebook.botframework.com","useAuth":true}, '/notify');

hi @venkaiahj - i've just added your solution and i'm getting the following error
ERROR: ChatConnector: startConversation - error starting conversation. Error: Failed to start conversation: no conversation ID returned.

i'm doing this in terminal with node app.js and mono BFEmulator.exe on mac

any ideas? thanks!

@bogdanfer what is the channel you r using?

"channelId":"facebook", i'm trying to get a "proactive" bot at the end of my waterfall to any channels (email, sms or facebook). but i can't get any to work.
update: in node

Hi palmerabollo,
I am going to use direct line or Twilio SMS for now as a Channel.

hi @ChandrikaC - did you get the SMS channel working? could you please share your beginDialog function?

@bogdanfer there was some issue with sms channelwhile authenticating its sending out the request, there is some isuse with that, it was not working with me also. facebbok and skype are working for me

we can make it work if u can edit file node_modules/botbuilder/lib/bots/chatConnector.js, in authenticate request function try to change "id" with "Id". it will work only for SMS. If u want to make it work for all of them put both the conditions

@venkaiahj - facebook could be good too. but i can't make it work. are you running your code from azure or local? i just deployed to azure and still not sending message to fb.
do you have an example for sms? I have the following:

session.beginDialog({
    from: {
        "address": "[twilio_number]",
        "channelId": "sms",
        "isBot": false
    },
    to: {
        "address": "[my_number]",
        "channelId": "sms",
        "isBot": false
    }
}, '/notify');

I am running from local, for facebook, skype the below is working
bot.beginDialog({"channelId":"facebook","user":{"id":"id of the user"},"bot":{"id":"id of the bot"},"serviceUrl":"https://facebook.botframework.com","useAuth":true}, '/notify');

for skype change channelId=''skype, and serviceUrl ='https://skype.botframework.com'
for sms change channelId='sms' and serviceUrl='https://sms.botframework.com', sms is not working for me, i have to edit file node_modules/botbuilder/lib/bots/chatConnector.js, in authenticate request function try to change "id" with "Id". it will work only for SMS. If u want to make it work for all of them put both the conditions

got you @venkaiahj thanks for the help! i'm still trying to get facebook work, still getting that

ERROR: ChatConnector: startConversation - error starting conversation.
Error: Failed to start conversation: no conversation ID returned.

i'll try some more times and if i get lucky i'll get back here with the fix.
thanks!

@bogdanfer @venkaiahj
you should be able to send a pro-active message doing the following:

var msg = new builder.Message()
                .address(session.message.address)
                .text("Here's your '%s' alarm.", alarm.title);
            bot.send(msg);

you'll notice the session.message.address in there, which means you can just save this value from a previous correspondence and supply it to your message whenever you want to send the pro-active message. You may find this easier than constructing the address yourself, and certainly easier than managing on a per-channel basis.

Let me know if you have further questions, I'm going to close this for now.

Hi @muzahmed , the above is not working for sms, its working for fb, skype.

for sms to work, i have to edit file node_modules/botbuilder/lib/bots/chatConnector.js, in authenticate request function try to change "id" with "Id". it will work only for SMS. If u want to make it work for all of them put both the conditions.

This is what I used to get it to work:

bot.beginDialog( { id: '+46704043717', channelId: 'sms', user: { id: '+46704123456', name: '+46704123456' }, conversation: {isGroup: false, id:'+46704123456'}, bot: { id: '+123456789', name: 'conference-bot' }, serviceUrl: 'https://sms.botframework.com', useAuth: false }, "notify:/");

where +123456789 is the Twilio number and +46704123456 is the receiving phone number. However this does only work if the user has communicated with the bot earlier at some point.

Was this page helpful?
0 / 5 - 0 ratings