收到欢迎信息后触发功能

时间:2019-08-02 07:09:06

标签: javascript botframework bots

我有一个Bot Web客户端。我在其中用以下代码触发欢迎消息。

directLine.postActivity({
from: { id: 'myUserId', name: 'myUserName' },
type: 'message',
 }).subscribe(
id => console.log("Posted activity, assigned ID ", id),
error => console.log("Error posting activity", error)
 );

在下面的欢迎消息中,我想拥有最受欢迎的商品。为此,在Subscribe下,我正在调用如下函数。

.subscribe( BotPostRender(););

它在收到欢迎消息之前正在渲染最受欢迎的项目,收到欢迎消息后有什么方法可以调用该函数?

function BotPostRender() {
$(".wc-message-group-content").append('<div class=feeds-wrapper><div class=chat-feeds><h5>Most Popular</h5><ul class=chat-feed-lists><li><a class=mp-options href=javascript:;>People</a><li><a class=mp-options href=javascript:;>Food Menu</a></ul></div></div>');
$(".mp-options").click(function (){GetResult($(this).text());});}

1 个答案:

答案 0 :(得分:0)

在BotChat.Js文件中,performWork是每当我们从机器人发送或接收消息时都会执行的功能。

在这种情况下,我已经编写了接收欢迎消息后调用我的函数的代码。

<?php
class dbConfig {
protected $serverName;
protected $userName;
protected $password;
protected $dbName;
function dbConfig() {
    $this -> serverName = 'localhost';
    $this -> userName = 'xxxx';
    $this -> password = 'xxxx';
    $this -> dbName = 'xxxx';
}
}
?>