Problem with Twitter direct message, No reply

IAM USING IBM NODE-RED WEBSITE
i'am trying to develop a chatbot with NodeRED uses the direct message from Twitter, The problem is i can't reply through direct message . from what i searched i have to add (( message_create.message_data message_create.target.recipient_id type but i don't now how to add them ???

message_create.message_data message_create.target.recipient_id type thats how within the Twitter API you specify that you are sending a DM.

But the twitter node hides the API complexity from you.

Have you read the Info panel for the twitter-out node? It specifies a far easier format for how to send a DM

You mean this one ? https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-event

i did not now how to write the code inside the function .....

That isn't the info panel for the twitter-out node in Node-RED

yah i know , but idon't know how to write it inside the function

look at the section "Concatenating strings" https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Strings

i trayed everything

msg.payload.d.username every single format
the message did not work it will not reply to direct message

the problem is : I TALK TO THE ACCOUNT THROUGH DIRECT MESSAGE, THE RAPLY FROM THE ACCOUNT IS TWEETING PUBLIC NOT TO THE SAME ACCOUNT HOW ASK THE QUESTION

msg.payload="D(space)@twitterusername(space)message"

and please do not shout

1 Like

i'am so sorry i will try it

add new function ? or to the same function ?

like this ?

@Malhakbani no, not like that.

Where Mark used (space) he intended you to put a space character there - just as it shows in the Twitter node help sidebar.

Lets say you want to send a DM to the @NodeRED twitter account to say "Hello". You would do:

msg.payload = "D @NodeRED Hello";
return msg;
1 Like

okay this is huge mistake thanks

"Error: No user matches for specified terms." this from the debug and what if i want him to send to any user @username will it work ?

and if you see the picture i created the dailog from ibm watson convesesn i want him to send the dailog

Maybe try without the @ in the username - I honestly can't remember if that's needed or not.

The usual rules apply as to which users you can DM - refer to the Twitter docs for those rules.

So in your Function you need to build up a String that looks like the one we've given you. That is where the information on String concatenation that @ukmoose linked you to would be useful.

and the username has to exist... and be set to accept DM from you.

i rayed multiple solution did not work

var dir1 ="D SkylineDynamics + dir1";
var dir2 =msg.payload.output.text[0];
var joined = dir1 + dir2;
return joined;