# Incoming Webhook Integration - "Post to Channel" parse as varible not possible

**URL:** <https://forums.rocket.chat/t/incoming-webhook-integration-post-to-channel-parse-as-varible-not-possible/12142>\
**Category:** Community Support\
**Created:** [September 9, 2021, 3:41pm UTC](https://forums.rocket.chat/t/incoming-webhook-integration-post-to-channel-parse-as-varible-not-possible/12142 "2021-09-09T15:41:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GaryFatt](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@GaryFatt](https://forums.rocket.chat/u/GaryFatt)\
**Post date:** [September 9, 2021, 3:41pm UTC](https://forums.rocket.chat/t/incoming-webhook-integration-post-to-channel-parse-as-varible-not-possible/12142/1 "2021-09-09T15:41:22Z")

</div>

### Description

I would like to be able to configure my incoming integration so that “Post to Channel” can be filled via the integration script rather than just putting a single #channel or @user. This is so that I can send Direct Messages to users of RocketChat based on what user is mentioned in the incoming webhook.

For example: If Max is added as a reviewer of code in our external app, I would like my rocketchat integration to send a Direct message to Max

**Firstly, does anyone have a method or solution to do this?** I could not find a method

I tried to find a workaround to do this as follows:

Create an Incoming webhook that posts to a #channel  
Create an outgoing webhook that triggers on messages to this channel  
This outgoing webhook will send messages to the api url = api/v1/chat.postMessage & using the script will input the @user thereby sending it via direct message

The API requires authentication that can be completed via the following headers “X-Auth-Token” & “X-User-ID”. These can be generated by sending a request to the api/v1/login url.

However i cannot seem to find a method of parsing the headers via the OutgoingJavaScript & therefore i keep running into the “status”:“error”,“message”:“You must be logged in to do this.”

**So Secondly, does anyone know how I can parse the headers via the outgoing script?**

I have tried in this is my script:  
Class Script {  
process\_outgoing\_request({request}) {  
let newheaders =  
{  
“X-User-ID”:   
“X-Auth-Token”:  
}

```
              return {
                      method: 'POST'
                      headers: newheaders
                      <Message information in format>
              }
       }
  }  

```

}

---

<div class="post-metadata">

**Author:** ![dudanogueira](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/dudanogueira/32/2529_2.png) [@dudanogueira](https://forums.rocket.chat/u/dudanogueira)\
**Post date:** [September 9, 2021, 7:11pm UTC](https://forums.rocket.chat/t/incoming-webhook-integration-post-to-channel-parse-as-varible-not-possible/12142/2 "2021-09-09T19:11:15Z")

</div>

> [@GaryFatt](#):
>
> “X-Auth-Token” & “X-User-ID”

Ok, maybe… this will solve your issue, or at least make you development easier.

When you generate a new token, it invalidates the previous one.

So instead of always generating a new token with login and password, you can create a personal access token and do it directly, without token invalidation issues, which may or may not be related to your issue.

If this doesn’t solve your problem, it would help to create a simulation environment, with payloads you would like to send for the integration webhooks.

---

<div class="post-metadata">

**Author:** ![GaryFatt](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@GaryFatt](https://forums.rocket.chat/u/GaryFatt)\
**Post date:** [September 10, 2021, 10:17pm UTC](https://forums.rocket.chat/t/incoming-webhook-integration-post-to-channel-parse-as-varible-not-possible/12142/3 "2021-09-10T22:17:11Z")

</div>

Thanks for your help.

I believe the X-Auth-Token is the same as the Personal access token, they seem to be interchangable when testing

I have a simulation environment using postman - in postman I am able to easily assign the headers & therefore I can autheticate & the api request works & posts a message. But when attempting through the outgoing webhook I cannot attach the headers via the script

---

<div class="post-metadata">

**Author:** ![trialsin](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@trialsin](https://forums.rocket.chat/u/trialsin)\
**Post date:** [March 13, 2022, 10:30am UTC](https://forums.rocket.chat/t/incoming-webhook-integration-post-to-channel-parse-as-varible-not-possible/12142/4 "2022-03-13T10:30:51Z")

</div>

There are a really esiest way todo that.

I’m using It in outgoing web Hook, but Works in incoming web hook too

Look my post:

> [@How to make Outgoing webhook respond just to the user that has send the command](https://forums.rocket.chat/t/how-to-make-outgoing-webhook-respond-just-to-the-user-that-has-send-the-command/13499):
>
> Description I would like send a outgoing webhook command and get the result just to the user that has sent the command. Now, when I send in general channel for example, all users get the command and the response of outgoing webhook Server Setup Information Version of Rocket.Chat Server: 3.18 Operating System: Ubuntu Deployment Method: Snap Number of Running Instances: 1 Any additional Information My current script is something like this: class Script { prepare\_outgoing\_…
