https://discord.gg/botpress logo
How to init user details using react components to...
# 🤝help
p
What exactly are you trying to achieve? What is your use case?
s
I want send some Article_id to the bot on starting the conversation so that it can fetch details from api
p
How does this relate to the title for this thread? Is the article you're sending going to change dynamically?
s
https://codesandbox.io/p/sandbox/react-web-share-forked-ks8nqy?file=%2Fsrc%2FApp.js%3A11%2C25 In this code what i am trying to achieve is Integrating a chatbot to a article page to interact with user based on article_id So on starting the conversation i like send the article_id in the metadata so that i can access it over the backend @prehistoric-airplane-85682
p
Ok yeah, so in your bot you can use a custom trigger in your workflow to capture the article Id and have your bot converse with the user on it. The only requirement is to be able to send a payload with the article Id to your bot. Here's a video about this:

https://www.youtube.com/watch?v=dDGY_wHFt3s▾

Does this help?
s
This approach won't work for us. First, we're using React components. Additionally, we need to send a payload with every message the user sends through the bot. Code we are using is like this import { Fab, Webchat } from '@square-energy-41150/webchat'; import { useState } from 'react'; function BotpressChat() { const [isWebchatOpen, setIsWebchatOpen] = useState(true); const handleToggleWebchat = () => { setIsWebchatOpen((prev) => !prev); }; return ( <Webchat clientId={CHAT_CONFIG.clientId} configuration={CHAT_CONFIG.headerConfig} style={{ ...chatStyles.webchat, display: isWebchatOpen ? 'flex' : 'none', }} /> ); } @prehistoric-airplane-85682
I got reply from the team @square-energy-41150 You may send "customData" with every message, and you can access it via "event.payload.customData" during that turn - only "userData" requires that special card to set the variables.