https://discord.gg/botpress logo
confused with coding part
# 🤝help
a
Copy code
import { Client } from "@botpress/chat";
import _ from 'lodash'; // Add this line to import lodash

const webhookId = "ID";

const main = async () => {
    const client = new Client({ apiUrl: `https://chat.botpress.cloud/${webhookId}` })

    const { user, key } = await client.createUser({})
    console.log(`User Id: ${user.id}`)

    const { conversation } = await client.createConversation({ 'x-user-key': key })
    console.log(`Conversation Id: ${conversation.id}`)

    const { message: incomingMessage } = await client.createMessage({ payload: { type: 'text', text: "hi" }, "x-user-key": key, conversationId: conversation.id })
    console.log(`Incoming Message Id: ${incomingMessage.id}`)

    if (incomingMessage.payload.type === 'text') {
        console.log(`Incoming: ${incomingMessage.payload.text}`)
    }
};

main();
and it shows me the result like
Copy code
User Id: userID
Conversation Id: conversationID
Incoming Message Id: messageID
Incoming: hi
Incoming message is same with send message otherwise when I check dashboard the conversation started and bot response correct answer but in terminal I'm not getting the correct response and not showing the answer that bot showed on dashboard ?! I'm just following the doc but still getting this. how can I send a message and get the message result from bot? Can someone provide an example code or give me a hint ?