azure chatbot SDK4-实时(人工)代理聊天REST API集成无法正常工作

时间:2019-03-19 11:35:58

标签: node.js azure botframework chatbot

我坚持使用Azure聊天机器人框架SDK4与使用Node.js的REST API通过实时代理(人)聊天进行集成。

  1. 我有一个REST API,需要在一定间隔内执行以获取有关人员座谈和状态的信息,并且我需要以聊天消息的形式发送给用户。
  2. 还有一个REST API,它将再次将聊天消息再次从用户发送到实时代理。

我正在尝试在azure聊天机器人SDK V4瀑布方法中实现此问题。

async liveAgentMsg(step) {
var msgObjMessages = await getLiveAgentMessages(); // API call
if (msgObjMessages.length > 0) {
    for(var i = 0; i < msgObjMessages.length; i++) {
        var msgtype = msgObjMessages[i].type;
        if ('ChatRequestSuccess' == msgtype) {
            await step.context.sendActivity("Chat request success.");
        } else if ('ChatEstablished' == msgtype) {
            return await step.prompt('textPrompt', 'Live agent chat established.');
        } else if ('ChatMessage' == msgtype) {
            await step.context.sendActivity(msgObjMessages [i].message.text);
        } else if ('ChatEnded' == msgtype) {
            await step.context.sendActivity(msgtype);
            return await step.endDialog();
        } else {
            await step.context.sendActivity(msgtype);
        }
    }
    return await step.replaceDialog(SAME_DIALOG_ID);
} }    


async chatMsg(step) {
if (step.result) {
    var chatObj = await sendChatMessage(step.result);  // API Call
    if ("success" == chatObj) {
        return await step.replaceDialog(SAME_DIALOG_ID);
    } else {
        await step.context.sendActivity(chatObj);
    }
} 
return await step.endDialog(); }

先谢谢了。

0 个答案:

没有答案