New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
possible error when adding routes #47
Comments
You need to supply the await bot.startExpressServer({
// add this:
app,
webhookVerifyToken: process.env.VERIFY_TOKEN,
port: process.env.PORT || 2040,
webhookPath: '/webhook',
}); Also, nit, perhaps you can move the async definition to the top, i.e: (async function() {
const app = express();
// ...
app.get('/hello', (req, res) => {
res.send('Hello World!')
})
})() |
Thank you very much, is it possible to integrate socket io too?
…On Sun, Jan 1, 2023, 2:00 AM Tony ***@***.***> wrote:
You need to supply the app value to the function for creating the server,
ie:
await bot.startExpressServer({
// Add this:
app,
webhookVerifyToken: process.env.VERIFY_TOKEN,port: process.env.PORT || 2040,webhookPath: /webhook,});
Also, nit, perhaps you can move the async definition to the top, i.e:
(async function() { const app = express();// ... app.get('/hello', (req, res) => {res.send('Hello World!')})})()
—
Reply to this email directly, view it on GitHub
<#47 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD74MWGSYJF6VVLRQY7OQYTWQETR5ANCNFSM6AAAAAATN2QECI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Thank you very much, is it possible to integrate socket io too? |
Most welcome. Unsure why you would need socket.io since you won't be able to integrate it with the Whatsapp app. Unless if you mean integration with your own service (e.g. your own frontend), then yes, you can definitely do it. |
That's right, I want to integrate it with my own interface |
I am developing it this way but the app stops. (async function() { // ... app.get('/hello', (req, res) => { await bot.startExpressServer({
}); If I comment these lines of the file, startExpressServer.js executes me correctly |
Hi @KevinJoseph, Did you manage to fix this? Can you clarify what you mean by |
Closing this due to insufficient info. @KevinJoseph, feel free to reopen :) |
Hi, I'm starting the following:
const { createBot } = require('whatsapp-cloud-api');
const axios = require('axios');
const express = require('express');
const app = express();
const from = process.env.WHATSAPP_PHONE_NUMBER_ID;
const token = process.env.WHATSAPP_TOKEN;
const webhookVerifyToken = process.env.VERIFY_TOKEN;
// Create a bot that can send messages
const bot = createBot(from, token);
(async function() {
await bot.startExpressServer({
webhookVerifyToken: process.env.VERIFY_TOKEN,
port: process.env.PORT || 2040,
webhookPath:
/webhook
,});
})();
app.get('/hello', (req, res) => {
res.send('Hello World!')
})
but when consulting the /hello route it gives me 404 as a result, is there an error with the route handler? thank you
The text was updated successfully, but these errors were encountered: