我想在我的机器人中创建订阅和取消订阅功能。为此,我认为将psid存储在数据库中,并在事件在线时通过Facebook bot向这些用户发送消息(仅适用于他们感兴趣的事件)。
我使用api.ai作为NPL和视觉工作室的webhook用于逻辑部分。
当用户调用具有此操作的intent时:event.on我想存储以下数据:事件类别(由用户填充),psid,收件人ID,payloag,message,triggerMessage。
代码如下:
else if ("event.on".Equals(request.result.action.ToLower()))
{
using (WebhookReceiverModelDataContext cts = new WebhookReceiverModelDataContext())
{
string message = request.result.resolvedQuery != null ? request.result.resolvedQuery : "";
string category = request.result.resolvedQuery != null ? request.result.resolvedQuery : "";
string triggerMessage = request.result.resolvedQuery != null ? request.result.resolvedQuery : "";
string recipientid = request.originalRequest.data.recipient.id;
string sender = request.originalRequest.data.sender.id;
cts.spTblBroadcast_CreateNew("SportCelebrity", "BroadcastData", message, sender, recipientid, category, triggerMessage, jsonRequest.ToString(), HttpContext.Current.User.Identity.Name);
speechLang = "You will be contacted when a new event will be online";
}
}
WebhookReceiverModel是这样的:
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.spTblBroadcast_CreateNew")]
public void spTblBroadcast_CreateNew([global::System.Data.Linq.Mapping.ParameterAttribute(Name="Source", DbType="NVarChar(50)")] string source, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Type", DbType="NVarChar(50)")] string type, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Message", DbType="NVarChar(MAX)")] string message, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Payload", DbType="NVarChar(MAX)")] string payload, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Sender", DbType="NVarChar(50)")] string sender, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Recipient", DbType="NVarChar(50)")] string recipientid, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Category", DbType="NVarChar(50)")] string category, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="TriggerMessage", DbType="NVarChar(50)")] string triggerMessage, [global::System.Data.Linq.Mapping.ParameterAttribute(Name="CreatedBy", DbType="NVarChar(50)")] string createdBy)
{
this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), source, type, message, payload, sender, recipientid, category, triggerMessage, createdBy);
}
see the store procedure : spTblBroadcast_CreateNew
当我填写消息的参数,triggermessage,类别我收到错误消息。
你能帮助我找到我错的地方......也许我所有的概念都不行,而且必须改变我的逻辑。我需要在我的机器人中添加这个功能......如果您有任何想法,我会非常感激。
json:
{
"id": "bc27-44e9-a5bf-6befa7a441d2",
"timestamp": "2018-02-14T13:29:59.833Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "2",
"action": "broadcast.data",
"actionIncomplete": false,
"parameters": {
"triggerMessage": "2",
"message": "text",
"category": "event"
},
"contexts": [],
"metadata": {
"intentId": "b1db-495c-9550-1781457ed779",
"webhookUsed": "true",
"webhookForSlotFillingUsed": "false",
"webhookResponseTime": 438,
"intentName": "notificguillaime"
},
"fulfillment": {
"speech": "",
"messages": [
{
"type": 0,
"platform": "facebook",
"speech": "notificguillaime has an error in system"
},
{
"type": 0,
"speech": ""
}
]
},
"score": 1
},
"status": {
"code": 206,
"errorType": "partial_content",
"errorDetails": "Webhook call failed. Error: 500 Internal Server Error",
"webhookTimedOut": false
},
"sessionId": "2eb7-4888-a9ac-5f7e9aaa2245"
}