howdyai / botkit

Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
MIT License
11.47k stars 2.28k forks source link

Unable to send message using botbuilder-adapter-webex #1755

Closed RamPrasadMeenavalli closed 4 years ago

RamPrasadMeenavalli commented 5 years ago

I am using the WebexAdapter from botbuilder-adapter-webex to connect my BotBuilder bot with Webex teams.

I have used the following code

const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
    console.log(`\n${ server.name } listening to ${ server.url }`);
    console.log(`\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator`);
    console.log(`\nTo test your bot, see: https://aka.ms/debug-with-emulator`);
});
var webexOptions = {
    access_token: process.env.ACCESS_TOKEN,
    public_address: process.env.PUBLIC_ADDRESS,
    secret: process.env.SECRET
}

const adapter = new WebexAdapter(webexOptions);
server.use(restify.plugins.bodyParser());
adapter.registerWebhookSubscription('/api/messages');
adapter.getIdentity();
server.post('/api/messages', (req, res) => {
    adapter.processActivity(req, res, async (context) => {
        await context.sendActivity('Hey human!!');
    });

When I post a message to the bot (in Webex Teams) the webhook gets called and the bot receives the user's message. At the step 'await context.sendActivity('Hey human!!');' it fails with the below error message

BadRequest: Unable to retrieve content. POST https://api.ciscospark.com/v1/messages WEBEX_TRACKING_ID: spark-js-sdk_9ba910cb-43ea-4800-88be-dde33e7ba825_7

I am using the following packages "botbuilder": "~4.5.1", "botbuilder-adapter-webex": "^1.0.2", "restify": "~8.3.3" Node version : v10.15.3

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

benbrown commented 4 years ago

@RamPrasadMeenavalli Did you ever sort this out?

I am not able to reproduce this issue.

RamPrasadMeenavalli commented 4 years ago

@benbrown - No. I haven't checked this after I reported the issue. I will check it again if I still face the issue. Thank you.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

AdityaJasti commented 4 years ago

@benbrown Hi Ben, I recently was working on an integration of MS Bot with WebEx Teams and faced this issue.

Below is the code i'm using to initiate the listening of webex adapter with MS bot using NodeJS.

const adapter = new WebexAdapter({ access_token: process.env.ACCESS_TOKEN, public_address: process.env.PUBLIC_ADDRESS, secret: process.env.SECRET });

const server = restify.createServer(); server.use(restify.plugins.bodyParser()); adapter.registerWebhookSubscription('/api/messages'); adapter.registerAdaptiveCardWebhookSubscription('/api/messages'); adapter.getIdentity();

server.post('/api/messages', (req, res) => {
adapter.processActivity(req, res, async (turnContext) => {
await turnContext.sendActivity('Hello User!'); }); });

After I post a message to the bot in webex teams, the webhook which i have created before,is getting called and the bot receives the user's message from webex teams.

the line in the above code - await turnContext.sendActivity('Hello User!'); is faling with the below error mesage.

[onTurnError] unhandled error: BadRequest: Both text and file cannot be empty. POST https://hydra-a.wbx2.com/v1/messages WEBEX_TRACKING_ID: webex-js-sdk_76d085fe-df79-4101-833c-3e53f4ec14ab_12

Im using NodeJS version - v12.14.1 My package.json dependencies are

"botbuilder": "~4.6.1", "botbuilder-adapter-webex": "1.0.7", "restify": "~8.4.0"

Request you to help me resolve this.