Chat message received, add output

Hello everyone, I wanted to know if it’s possible to customize the outputs received in the “chat message received” trigger in order to have an additional column.

I would like to identify the users of my WordPress site to offer them a personalized experience. For that, I would need to retrieve their user IDs as an output to load the memory corresponding to each user.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @TomLaizy,

This depends on whether you want to use the Hosted Chat or Embedded Chat option. Hosted chat would be a standalone chat interface provided by n8n and easy to setup, but if you want to integrate the chat functionality into your own website (e.g. Wordpress) I recommend choosing the Embedded option.

Embedded Chat
In embedded chat, you can include custom metadata (e.g. wordpress_id) directly in the createChat function when embedding the chat on your own webpage. The metadata can be any json object and that should get passed along in the Chat Trigger:

createChat({
    webhookUrl: 'your-webhook-url',
    metadata: {
        wordpress_id: 'username',
        wordpress_email: '[email protected]'
    },
  });

See @n8n/chat - npm for details. There’s also a similar post here.

Hosted Chat
In a hosted chat, if you set an Authentication, the chat will pass on the user details in the metadata (e.g. if you select n8n User Auth you’ll see the n8n user details in the metadata like so:

CleanShot 2024-09-18 at 09.54.38

Here’s a related post: Is there a way to pass query parameters in the Chat trigger? - #3 by miguel-mconf

Hope that helps!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.