# Problem with Twitter direct message, No reply

**URL:** <https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397>\
**Category:** General\
**Created:** [30 January 2019 14:29 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397 "2019-01-30T14:29:15Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 February 2019 23:41 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/44 "2019-02-01T23:41:36Z")

</div>

So you need to build the string:

```auto
"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.

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [1 February 2019 23:44 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/45 "2019-02-01T23:44:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 February 2019 23:45 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/46 "2019-02-01T23:45:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [1 February 2019 23:46 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/47 "2019-02-01T23:46:26Z")

</div>

my account is public

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [1 February 2019 23:48 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/48 "2019-02-01T23:48:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [1 February 2019 23:50 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/49 "2019-02-01T23:50:43Z")

</div>

> [@Malhakbani](#):
>
> my account is public

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.

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [1 February 2019 23:55 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/50 "2019-02-01T23:55:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [1 February 2019 23:56 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/51 "2019-02-01T23:56:40Z")

</div>

![15%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b20492b341963ccda5ae5b27cf416fb6ce6faaf0.png)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [2 February 2019 00:00 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/52 "2019-02-02T00:00:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [2 February 2019 00:01 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/53 "2019-02-02T00:01:56Z")

</div>

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

i will try  
thanks man

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [2 February 2019 00:03 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/54 "2019-02-02T00:03:21Z")

</div>

> [@Malhakbani](#):
>
> i don't not property that contains the username

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.

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [2 February 2019 00:05 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/55 "2019-02-02T00:05:10Z")

</div>

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

i will do what you said

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [2 February 2019 00:11 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/56 "2019-02-02T00:11:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [2 February 2019 01:57 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/57 "2019-02-02T01:57:21Z")

</div>

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;
```

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [2 February 2019 01:58 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/58 "2019-02-02T01:58:53Z")

</div>

the debug window :

 ![17%20AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/55d26f07f3cefd3a006a0c4c6fe07bab2512b8ad.png)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 February 2019 07:19 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/59 "2019-02-02T07:19:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [2 February 2019 08:33 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/60 "2019-02-02T08:33:21Z")

</div>

```
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"`

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [2 February 2019 08:39 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/61 "2019-02-02T08:39:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Malhakbani](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@Malhakbani](https://discourse.nodered.org/u/Malhakbani)\
**Post date:** [2 February 2019 17:33 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/62 "2019-02-02T17:33:14Z")

</div>

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;
> 
> ```

 ![57%20PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/834caee17d7b35fa8222b91e55e668ab09d85fb7.png)

---

<div class="post-metadata">

**Author:** ![dennings](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dennings/32/39348_2.png) [@dennings](https://discourse.nodered.org/u/dennings)\
**Post date:** [5 February 2019 20:22 UTC](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397/63 "2019-02-05T20:22:53Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397.md?page=2)

[Next page](https://discourse.nodered.org/t/problem-with-twitter-direct-message-no-reply/7397.md?page=4)
