Skip to content
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

Cannot read properties of undefined createDirectLine #5387

Open
1 of 9 tasks
Rakesh061296 opened this issue Jan 27, 2025 · 0 comments
Open
1 of 9 tasks

Cannot read properties of undefined createDirectLine #5387

Rakesh061296 opened this issue Jan 27, 2025 · 0 comments
Labels
type:bug-suspected Suspected bug (not working as designed/expected). See type:bug-confirmed for confirmed bugs

Comments

@Rakesh061296
Copy link

Disclaimer

Yes

Sample

import { createDirectLine } from 'botframework-webchat';

Contributor(s)

ghost

What happened?

i am Using these Version for SPFx version 1.20.0

 

For SPFx version 1.20.0, here are the compatible versions of Node.js, React, TypeScript, and other required tools/packages you should install:

 

Summary of Required Versions:

Tool/Library | Version -- | -- Node.js | 18.x React | 17.x React-DOM | 17.x TypeScript | 4.7.x Gulp | 4.x Fluent UI | 8.x PnP SPFx Controls React | 3.20.0

Image

Steps to reproduce

1.If createDirectLine is still not available, double-check your Web Chat library version and dependencies.
2.
3.

Expected behavior

const createDirect = async (botURL: string, regionalChannelURL: string) => {
try {
const response = await fetch(botURL);

if (!response.ok) {
  if (response.status === 403) {
    throw new Error('Access Forbidden: Token might be invalid or expired.');
  } else if (response.status === 404) {
    throw new Error('Bot service not found. Check bot URL configuration.');
  } else {
    throw new Error(`HTTP error! Status: ${response.status}`);
  }
}

const conversationInfo = await response.json();

if (window.WebChat && window.WebChat.createDirectLine) {
  return window.WebChat.createDirectLine({
    token: conversationInfo.token,
    domain: `${regionalChannelURL}v3/directline`,
  });
} else {
  throw new Error('WebChat.createDirectLine is not available. Check the Web Chat library.');
}

} catch (error) {
Log.error('Failed to create DirectLine:', error);
setIsTokenExpired(true); // Show dialog for expired token
throw error; // Pass the error up to the boundary
}
};

Target SharePoint environment

SharePoint Online

Developer environment

None

Browsers

  • Internet Explorer
  • Microsoft Edge
  • Google Chrome
  • FireFox
  • Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

What version of Node.js is currently installed on your workstation?

18

What version of Node.js is required by the sample?

18

Paste the results of SPFx doctor

Image

Additional environment details

No response

@Rakesh061296 Rakesh061296 added the type:bug-suspected Suspected bug (not working as designed/expected). See type:bug-confirmed for confirmed bugs label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug-suspected Suspected bug (not working as designed/expected). See type:bug-confirmed for confirmed bugs
Projects
None yet
Development

No branches or pull requests

1 participant