I have the dialogflow cx chat widget integrated with my Joomla site. I want to get the logged in user id so that I can retrieve user specific info. I obtain the logged in user id in my php webhook in $userid and confirmed it is correct. I've added the script to the template of the site which provided the
<script src="https://www.gstatic.com/dialogflow-console/fast/messenger-cx/bootstrap.js?v=1"></script>
<df-messenger
df-cx="true"
user-id="Random"
location="us-central1"
chat-title="Hello"
agent-id="d62e52e5-c6aa-xxxxxxxxxx-f49b0bc6af31"
language-code="en"
></df-messenger>
<script>
var my_id = '<$php echo $userid ; ?>';
const dfMessenger = document.querySelector('df-messenger');
dfMessenger.setAttribute("user-id", my_id );
</script>
I'm attempting to pass the $userid value into the user-id payload field as shown above but cannot arrive at the correct syntax it seems. I've tried many variations.
The above results in this in the request message:
"payload": {
"userId": "<?=$userid?>"
},
All suggestions are welcome.... thanks.