Problem with Twitter direct message, No reply

So you need to build the string:

"D username message"

It's clear that the message part comes from msg.payload.output.text[0]

What message property contains the username you want to reply to?

Each of the code examples you've shared seems to do something different for the username.... so it's hard to know what you have.

i want to reply to anyone how contact me
"D username" +msg.payload.output.text[0] this one works but i have to specified the name like this:
"D knolleary" +msg.payload.output.text[0] and it will work but i want to be globally for anyone i did not know how

Yes, I understand what you want to do, but I have no idea how people are contacting you in the first place. How do you know what their username is?

my account is public

i don't know their username i want to be able for anyone

You have never described your full scenario. All you've said is you want to create a chatbot and reply using a direct message.

So we have to assume you mean they will tweet at you? Does that mean you have a Twitter In node at the start of your flow? If that is the case, then the sidebar help for the Twitter In node tells you what properties are available on the message.

Also, if you wire a Debug node after the Twitter In node and configure the Debug node to display the complete message, you can see the messages and explore it to find the username field you need.

i'am sorry if i was not clear and i appreciate your help
Yes i have Twitter account in the start of the flow where he will get any one how contact me through direct message . and i wired the node with the debug and in the sidebar he showed me the name of the account but still not possible to make it dynamic for any account to reply to

If you know what property on the message contains the username then you should be able to use that in your Function node to build the proper string.

The only problem will be the Chatbot node - I don't know off the top of my head if that node passes through all message properties, or if it only returns the properties from the Watson Conversation service.

yes this is problem i don't not property that contains the username

i will try
thanks man

I have given you advice on how to find that out. Use a Debug node set to display the complete message - not just msg.payload as you have it currently. Also read the Twitter In node help. You have all the pointers I can give you. Good luck.

i found this one https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object.html

i will do what you said

i FOUND IT after node set to display the complete message tweet.sender_screen_name

unfortunately did not work i tried this and much much more every solution any body can think of :

msg.payload ="D $msg.payload.tweet.sender_screen_name "+msg.payload.output.text[0];
return msg;
var name = tweet.sender_screen_name;
msg.payload ="D $name "+msg.payload.output.text[0];
return msg;

msg.payload.account= "D"
msg.payload.user = tweet.sender_screen_name
msg.payload.join = `"${msg.payload.account+msg.payload.user }"`
msg.payload =msg.payload.join+msg.payload.output.text[0];
return msg;

var account= "D"
var user = tweet.sender_screen_name
var join = `"${msg.payload.account+msg.payload.user }"`
msg.payload =msg.payload.join+msg.payload.output.text[0];
return msg;

the debug window :

your javascript knowledge on how to concatenation strings appears to be rusty. Look at the 7th post in the thread for a refresher

var name = "msg.payload.tweet.sender_screen_name";
var text = "msg.payload.output.text[0]";

msg.payload = "D " + name + text;
return msg;

RESULIT :
"TypeError: Cannot read property 'slice' of null"

1 Like

So add a debug node and compare what you are sending to the message you know that works...

Finally with hardwork and long hours no sleep and all the help from you guys thank you so much
@ukmoose @knolleary thanks much love
final project :
the code in the function is :

           var text = msg.payload.output.text[0];
            var username = msg.tweet.sender.screen_name;
            msg.payload =`D ${username} `+text;
            return msg;

Remark: I just tested the same. The "name" MUST be withot the "@" char... then i got the message :wink: