为了使Google助手能够向用户显示丰富的响应,必须向其提供响应,例如Google文档上的操作中的示例。但是,由于我将Dialogflow用作服务器和Google之间的中介方,因此我需要在Webhooks中提供对Dialogflow的某种响应,以表明应该有丰富的响应。从该链接可以看到,该文档提到了如何向FB Messenger,Kik,LINE等发送丰富的响应,但没有向Google Assistant发送响应。
我在这里想念什么?我在Dialogflow Web控制台中看到了用于丰富响应的选项,但在这里似乎只能输入硬编码的响应,而没有来自服务器的动态数据。什么是正确的方法?
我想使用 .htaccess 将链接到个人资料页面的 URL 从 ID 号转换为名称。例如,在 Facebook 上,如果您要访问:
https://facebook.com/profile.php?id=4
Run Code Online (Sandbox Code Playgroud)
它会将您带到马克·扎克伯格的个人资料页面。但是,您也可以简单地访问:
https://facebook.com/zuck
Run Code Online (Sandbox Code Playgroud)
...这对用户更友好并且更容易记住。如何使用 htaccess 将 ID 号转换为用户名?我是否需要将其发送到 php 脚本来处理并发回名称?
我要收藏的MongoDB,让我们称他们parents和children.这个父母/孩子的设计有一对多的关系,当我查询父母时我也想要孩子.根据这个逻辑,有这个模型设计是有道理的:
var ParentSchema = new Schema({
name: String,
children: [{type: Schema.Types.ObjectID, ref: 'Child'}]
});
var ChildSchema = new Schema({
name: String
});
Run Code Online (Sandbox Code Playgroud)
这样,我可以populate()用来轻松地让孩子与父母一起.但是,我被告知使用这样的数组并不好,因为它们会变得混乱.所以,如果我把对象引用放在ChildSchema那里,那么我可以避免使用这样的数组.
var ParentSchema = new Schema({
name: String
});
var ChildSchema = new Schema({
name: String,
parent: {type: Schema.Types.ObjectID, ref: 'Parent'}
});
Run Code Online (Sandbox Code Playgroud)
但是,如果我想再次与父母一起生孩子,populate()将无法工作.什么是最好的模式,如果我在孩子们使用refs,有没有类似的方法populate()呢?我不喜欢做查询以获得一个结果.
假设我有两个Mongoose集合- conversation和message-,并且我想显示特定用户所在的对话列表,按最新消息排序,并在对话名称下方显示该消息的预览
在获得用户的对话之后,如何才能仅从每个对话中选择最新消息,并将这些消息附加到其相应的对话中?(鉴于架构看起来像这样):
var ConversationSchema = new Schema({
name: String,
participants: {
type: [{
type: Schema.Types.ObjectId,
ref: 'User'
}]
}
});
var MessageSchema = new Schema({
conversation: {type: Schema.Types.ObjectId, ref: 'Conversation', required: true},
text: {type: String, required: true},
user: {type: Schema.Types.ObjectId, ref: 'User', required: true}
});
Run Code Online (Sandbox Code Playgroud)
我收到的消息是我可能应该使用Mongo的“聚合”框架,但是我以前从未使用过它,因此我需要一些帮助。谢谢!
mongoose mongodb node.js mongodb-query aggregation-framework
如果我有一个 model Attachment,它可以分为 4 种类型:Link、YoutubeVideo、GoogleDriveFile、 和GoogleDriveFolder,我如何使用 Mongoose 区分Attachment这些类型,并允许它们成为另一个模式中的子文档;Post?
我创建了基本Attachment模型,并使用判别器将其划分为单独的模型:
var AttachmentSchema = new Schema({
id: {type: String, required: true},
title: {type: String, required: true}
});
var Attachment = mongoose.model('Material', AttachmentSchema);
module.exports = {
DriveFile: Attachment.discriminator('GoogleDriveFile', new mongoose.Schema()),
DriveFolder: Attachment.discriminator('GoogleDriveFolder', new mongoose.Schema()),
Link: Attachment.discriminator('Link', new mongoose.Schema()),
YoutubeVideo: Attachment.discriminator('YoutubeVideo', new mongoose.Schema())
};
Run Code Online (Sandbox Code Playgroud)
现在,在Post架构中,应该有一系列具有不同类型的附件:
var Attachment = require('./attachment');
var PostSchema = new Schema(
text:{type: String},
attachments: …Run Code Online (Sandbox Code Playgroud)