Facing issue While creating the Moralis Stream

I need help with Moralis streams. I am trying to create a stream to listen to wallet native currency transactions. I created the webhook file and am listening through ngrok. It works fine when I create the stream from the Moralis admin panel, but when I create the stream through the script, it doesn’t listen. What is the issue, and how can I resolve it?

webhook.js

const express = require(“express”);
const app = express();
const port = 7000;

app.use(express.json());

app.post("/webhook", async (req, res) => {
console.log(“Received a webhook call”);
const { body } = req;
try {
console.log(“body”, body);
} catch (err) {
console.log(err);
return res.status(400).json();
}
return res.status(200).json();
});

app.listen(port, () => {
console.log(“Listening to Stream”);
});

index.js

const Moralis = require(“moralis”).default;
Moralis.start({
apiKey:
config.key,
});
const runApp = async () => {
const option = {
webhookUrl: “https://15ca-103-105-211-114.ngrok-free.app/webhook”, // replace with your own webhook URL
description: “My first stream”,
tag: “my_stream”,
chains: [“0x61”],
includeNativeTxs: true,
includeInternalTxs: true,
};
const newResponse = await Moralis.Streams.add(option);

const { id } = newResponse.toJSON(); // print the stream id
console.log("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>", id);
const address = [
“0x522d9256ac9Dc7Ce6bacCDeD78F2318f0A109e50,0x02a2C3ec13b3f2d9C9bFc3B78Be00bA5804276e2”,
];
await Moralis.Streams.addAddress;
({ address, id });
console.log(“Run”);
};

runApp();

Hi @umaidkhalid85

If the streams are successfully created through your code, you will find them on the below streams page
https://admin.moralis.io/streams

The first thing I would suggest you check is if there are any errors in delivering the webhook to your webhook URL.
You can check the logs on the below page.
https://admin.moralis.io/streams/failed

To Kynect@umaidkhalid85,

In your code snippet, you are missing the await keyword when calling Moralis.Streams.addAddress. The address array should contain addresses as strings, but in your code, they are combined into a single string with commas.

Ensure that your Express server (webhook.js) is correctly configured to receive POST requests at /webhook and that it is accessible via ngrok or your chosen tunneling service.