2

Is there a way to set webhook headers by code?

I'd like to send an authorization header to the fulfillment webhook but I need to set it dynamically from code (using nodejs)

At the moment my headers are empty. enter image description here

Alexandre B.
  • 5,387
  • 2
  • 17
  • 40
ddalbosco
  • 169
  • 1
  • 5
  • Perhaps if you can flesh out the back-story it would help. For example, are you trying to perform the processing of the request as a function of the user making the request? What is the logical purpose of the extra headers? – Kolban May 22 '19 at 14:20
  • @Kolban The frontend has an authentication token that I pass to a cloud function (called "question") that checks the authentication and then performs a call to dialogflow apis. I need to retrieve this auth token inside my fulfillment (cloud function) in order to access another api that uses this token. At the moment I'm doing this by putting the token inside request payload. – ddalbosco May 23 '19 at 09:17
  • I am trying to do something similar. Have you found a way to add dynamic headers to the webhook or did you have to use the inline editor? – Gene Jan 09 '20 at 11:45
  • @Gene No, I'm still adding by code (nodejs) a parameter into the payload of to the dialogflow request (queryParams.payload) – ddalbosco Jan 09 '20 at 15:33

1 Answers1

0

Currently, you could pass a header via webhookHeaders of the QueryParameters object. It's available from v2beta1 version. Check it out https://cloud.google.com/dialogflow/docs/reference/rest/v2beta1/QueryParameters