NGRP / node-red-contrib-viseo

Node-RED nodes OpenSourced by VISEO Technologies
Apache License 2.0
227 stars 83 forks source link

How to display a variable when you send a msg to the use ? #64

Closed samuelguesnier closed 6 years ago

samuelguesnier commented 6 years ago

Hi, I'm trying to display the user's name who is talking to the bot. here is the schema https://image.noelshack.com/fichiers/2017/42/3/1508324113-capture-du-2017-10-18-12-54-56.png The code in function "get name" is : msg.payload = msg.user.profile.first_name; return msg;

The function return the name, but I can't send it back to the user, because in send message {msg.payload} display nothing. So it just send "hi" Someone can help me ? Thanks

JpEncausse commented 6 years ago

You should simply do: BotBuilder > FBProfile > Message In you message don't set the msg part only {user.profile.first_name} the {} works on the object in the flow.

By the way you should pipe: BotBuilder > DB Get User > Profile > FBProfile > DB Save User > Message

Use user.id as key to retrieve the user from database. later you can set data in the user profile and retrieve it that way.

samuelguesnier commented 6 years ago

Ho great ! It works :)

By the way you should pipe: BotBuilder > DB Get User > Profile > FBProfile > DB Save User > Message Use user.id as key to retrieve the user from database. later you can set data in the user profile and retrieve it that way.

I'm not sure to understand : The message received is piped to Get User to verify if the user is in the databse, if yes we put it in Profile, if not we parse the Data with FB Profile , then we save it in the DB and finally we can send the message ?

JpEncausse commented 6 years ago

if yes we put it in Profile, if not we parse the Data with FB Profile ,

We merge the user (or not) retrieve from db with the profile from bot builder then we merge it with it's facebook profile (with more data) then we save it yes

The FBProfile has an internal timeout to avoid requesting user data for each message

samuelguesnier commented 6 years ago

Humm ok , and also, can I ask you why 2 profiles nodes is needed ? Is it because the messange can income from multiples sources like skype ?

JpEncausse commented 6 years ago

The first profile node is an all purpose profile working with all BotBuilder channels. The Facebook Profile will query facebook to get more data

samuelguesnier commented 6 years ago

Ho, ok I see. Thank you JP :+1: