botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Skype For Business]Error: Failed to start conversation: no conversation ID returned issue.

Open amitgobare23 opened this issue 9 years ago • 3 comments

  • SDK Platform: Node.js

  • Active Channels: Skype For Business

  • Deployment Environment: Auzure Bot Service

Issue Description

It shows below exception:

Error: Failed to start conversation: no conversation ID returned. and
ChatConnector: startConversation - error starting conversation.
Error: Request to 'https://api.skypeforbusiness.com/platformservice/botframework/v3/conversations' failed: [500] Internal Server Error at Request._callback

Code Example

module.exports = function (context, myTimer) {
    const builder = require('botbuilder');
    const GraphService = require('graph-service');
    const appInsights = require("applicationinsights");    
    const tenant = process.env['tenant'];
    const clientId = process.env['clientId'];
    const clientSecret = process.env['clientSecret']
    const api = new GraphService(tenant, clientId, clientSecret);

    appInsights.setup()
        .setAutoDependencyCorrelation(false)
        .setAutoCollectRequests(true)
        .setAutoCollectPerformance(true)
        .setAutoCollectExceptions(true)
        .setAutoCollectDependencies(true)
        .start();

    let client = appInsights.defaultClient;

    const sendProactiveMessage = (addressToInitiate) => {

        var addr = {
            id:"",
            channelId:"skypeforbusiness",
            user:{
                id:"sip:emaiId"
            },
            channelData: {
                    tenant: {
                        id: process.env['tenant']
                    }
                },
            bot:
            {
                id: process.env['botId'],
                name: process.env['botName']
            },
            serviceUrl:process.env['serviceUrl']              
        };
        
        let msg = new builder.Message().address(addr).text("Hello");
        bot.send(msg, function(err, address){
            context.log(err);
            context.log(address); //Address is showing null here.
        });
        context.log("Message sent to: " + addr.user.id);
    }

    var connector = new builder.ChatConnector({
        appId: process.env['appId'],
        appPassword: process.env['appPassword']
    });

    var bot = new builder.UniversalBot(connector);
    var addressesToInitiate = ["sip:emailId"];

    addressesToInitiate.forEach(function (addressToInitiate) {                
        sendProactiveMessage(addressToInitiate);        
    });
    context.done();
};

Expected Behavior

We are expected that bot.send() give address as response and in address we required conversation Id.

amitgobare23 avatar Sep 19 '17 12:09 amitgobare23

Hi, I am still waiting workaround regarding same could you please help me for my query as i mentioned above.

Regards, Amit Gobare.

amitgobare23 avatar Sep 26 '17 07:09 amitgobare23

@amitgobare23 You have constructed an address object manually, but that won't work... you need to get the address information from the context.conversationReference object from an actual conversation with a real user.

If your bot has not contacted the end user at least once, and save the address info somehow, then the bot will not have the correct address information to be able to send the proactive message.

Please refer to this documentation on sending proactive messages: https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-proactive-messages

You can also find a working code example for reference here: https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-proactiveMessages

nwhitmont avatar Oct 10 '17 00:10 nwhitmont

For skype the conversation id remains same for one particular user but in case of skype for business the conversation id changes the number of times you initiate chat with user. So how can a bot be a ble to send proactive message. Ideally bot should be able to send the proactive message based on sip address.

sdharshraj avatar May 16 '18 13:05 sdharshraj